stato intermedio
This commit is contained in:
@@ -1,21 +1,38 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type EmailVerificationToken struct {
|
||||
ID uint `gorm:"primaryKey"`
|
||||
UserID uint `gorm:"not null;index"`
|
||||
ID string `gorm:"primaryKey"`
|
||||
UserID string `gorm:"not null;index"`
|
||||
TokenHash string `gorm:"size:64;uniqueIndex;not null"`
|
||||
ExpiresAt time.Time `gorm:"not null;index"`
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
|
||||
func (token *EmailVerificationToken) BeforeCreate(tx *gorm.DB) (err error) {
|
||||
// UUID version 4
|
||||
token.ID = uuid.NewString()
|
||||
return
|
||||
}
|
||||
|
||||
type PasswordResetToken struct {
|
||||
ID uint `gorm:"primaryKey"`
|
||||
UserID uint `gorm:"not null;index"`
|
||||
ID string `gorm:"primaryKey"`
|
||||
UserID string `gorm:"not null;index"`
|
||||
TokenHash string `gorm:"size:64;uniqueIndex;not null"`
|
||||
ExpiresAt time.Time `gorm:"not null;index"`
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
|
||||
func (token *PasswordResetToken) BeforeCreate(tx *gorm.DB) (err error) {
|
||||
// UUID version 4
|
||||
token.ID = uuid.NewString()
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user