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.DNSLink{},
|
||||
&models.Download{},
|
||||
&models.EmailVerification{},
|
||||
&models.PasswordReset{},
|
||||
&models.Pin{},
|
||||
&models.PublicKey{},
|
||||
&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
|
||||
}
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue