init push
This commit is contained in:
32
internal/domain/auth/security_pin_reset_token.go
Normal file
32
internal/domain/auth/security_pin_reset_token.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package auth
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
|
||||
"wucher/internal/shared/pkg/uuidv7"
|
||||
)
|
||||
|
||||
type SecurityPINResetToken struct {
|
||||
ID []byte `gorm:"type:binary(16);primaryKey;column:id"`
|
||||
UserID []byte `gorm:"type:binary(16);index;not null;column:user_id"`
|
||||
TokenHash []byte `gorm:"type:varbinary(32);uniqueIndex;not null;column:token_hash"`
|
||||
ExpiresAt time.Time `gorm:"index;not null;column:expires_at"`
|
||||
UsedAt *time.Time `gorm:"index;column:used_at"`
|
||||
RequestedIP string `gorm:"type:varchar(128);column:requested_ip"`
|
||||
UserAgent string `gorm:"type:varchar(255);column:user_agent"`
|
||||
CreatedAt time.Time
|
||||
CreatedBy []byte `gorm:"type:binary(16);column:created_by"`
|
||||
UpdatedAt time.Time
|
||||
UpdatedBy []byte `gorm:"type:binary(16);column:updated_by"`
|
||||
}
|
||||
|
||||
func (SecurityPINResetToken) TableName() string { return "security_pin_reset_tokens" }
|
||||
|
||||
func (prt *SecurityPINResetToken) BeforeCreate(tx *gorm.DB) error {
|
||||
if len(prt.ID) == 0 {
|
||||
prt.ID = uuidv7.MustBytes()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user