feat: add password reset, account verification models, and a verified field to users
This commit is contained in:
parent
3da1ae3e5f
commit
1be4fb47fc
2
db/db.go
2
db/db.go
|
@ -65,6 +65,8 @@ func NewDatabase(lc fx.Lifecycle, params DatabaseParams) *gorm.DB {
|
||||||
&models.Blocklist{},
|
&models.Blocklist{},
|
||||||
&models.DNSLink{},
|
&models.DNSLink{},
|
||||||
&models.Download{},
|
&models.Download{},
|
||||||
|
&models.EmailVerification{},
|
||||||
|
&models.PasswordReset{},
|
||||||
&models.Pin{},
|
&models.Pin{},
|
||||||
&models.PublicKey{},
|
&models.PublicKey{},
|
||||||
&models.Upload{},
|
&models.Upload{},
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
package models
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"gorm.io/gorm"
|
||||||
|
)
|
||||||
|
|
||||||
|
type EmailVerification struct {
|
||||||
|
gorm.Model
|
||||||
|
|
||||||
|
UserID uint
|
||||||
|
User User
|
||||||
|
NewEmail string
|
||||||
|
Token string
|
||||||
|
ExpiresAt time.Time
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
package models
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"gorm.io/gorm"
|
||||||
|
)
|
||||||
|
|
||||||
|
type PasswordReset struct {
|
||||||
|
gorm.Model
|
||||||
|
|
||||||
|
UserID uint
|
||||||
|
User User
|
||||||
|
Token string
|
||||||
|
ExpiresAt time.Time
|
||||||
|
}
|
|
@ -24,6 +24,9 @@ type User struct {
|
||||||
OTPVerified bool `gorm:"default:false;"`
|
OTPVerified bool `gorm:"default:false;"`
|
||||||
OTPSecret string
|
OTPSecret string
|
||||||
OTPAuthUrl string
|
OTPAuthUrl string
|
||||||
|
Verified bool `gorm:"default:false;"`
|
||||||
|
EmailVerifications []EmailVerification
|
||||||
|
PasswordResets []PasswordReset
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *User) BeforeUpdate(tx *gorm.DB) error {
|
func (u *User) BeforeUpdate(tx *gorm.DB) error {
|
||||||
|
|
Loading…
Reference in New Issue