diff --git a/db/db.go b/db/db.go index 6cdb911..de45ed6 100644 --- a/db/db.go +++ b/db/db.go @@ -65,6 +65,8 @@ func NewDatabase(lc fx.Lifecycle, params DatabaseParams) *gorm.DB { &models.Blocklist{}, &models.DNSLink{}, &models.Download{}, + &models.EmailVerification{}, + &models.PasswordReset{}, &models.Pin{}, &models.PublicKey{}, &models.Upload{}, diff --git a/db/models/email_verification.go b/db/models/email_verification.go new file mode 100644 index 0000000..ed386ec --- /dev/null +++ b/db/models/email_verification.go @@ -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 +} diff --git a/db/models/password_reset.go b/db/models/password_reset.go new file mode 100644 index 0000000..539f216 --- /dev/null +++ b/db/models/password_reset.go @@ -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 +} diff --git a/db/models/user.go b/db/models/user.go index bc1e61b..cf31d1e 100644 --- a/db/models/user.go +++ b/db/models/user.go @@ -10,20 +10,23 @@ import ( type User struct { gorm.Model - FirstName string - LastName string - Email string `gorm:"unique"` - PasswordHash string - Role string - PublicKeys []PublicKey - APIKeys []APIKey - Uploads []Upload - LastLogin *time.Time - LastLoginIP string - OTPEnabled bool `gorm:"default:false;"` - OTPVerified bool `gorm:"default:false;"` - OTPSecret string - OTPAuthUrl string + FirstName string + LastName string + Email string `gorm:"unique"` + PasswordHash string + Role string + PublicKeys []PublicKey + APIKeys []APIKey + Uploads []Upload + LastLogin *time.Time + LastLoginIP string + OTPEnabled bool `gorm:"default:false;"` + OTPVerified bool `gorm:"default:false;"` + OTPSecret string + OTPAuthUrl string + Verified bool `gorm:"default:false;"` + EmailVerifications []EmailVerification + PasswordResets []PasswordReset } func (u *User) BeforeUpdate(tx *gorm.DB) error {