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
|
||||||
|
}
|
|
@ -10,20 +10,23 @@ import (
|
||||||
|
|
||||||
type User struct {
|
type User struct {
|
||||||
gorm.Model
|
gorm.Model
|
||||||
FirstName string
|
FirstName string
|
||||||
LastName string
|
LastName string
|
||||||
Email string `gorm:"unique"`
|
Email string `gorm:"unique"`
|
||||||
PasswordHash string
|
PasswordHash string
|
||||||
Role string
|
Role string
|
||||||
PublicKeys []PublicKey
|
PublicKeys []PublicKey
|
||||||
APIKeys []APIKey
|
APIKeys []APIKey
|
||||||
Uploads []Upload
|
Uploads []Upload
|
||||||
LastLogin *time.Time
|
LastLogin *time.Time
|
||||||
LastLoginIP string
|
LastLoginIP string
|
||||||
OTPEnabled bool `gorm:"default:false;"`
|
OTPEnabled bool `gorm:"default:false;"`
|
||||||
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