feat: add password reset, account verification models, and a verified field to users

This commit is contained in:
Derrick Hammer 2024-02-26 07:47:05 -05:00
parent 3da1ae3e5f
commit 1be4fb47fc
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
4 changed files with 52 additions and 14 deletions

View File

@ -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{},

View File

@ -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
}

View File

@ -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
}

View File

@ -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 {