init push
This commit is contained in:
30
internal/domain/auth/totp.go
Normal file
30
internal/domain/auth/totp.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package auth
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
|
||||
"wucher/internal/shared/pkg/uuidv7"
|
||||
)
|
||||
|
||||
type UserTOTP struct {
|
||||
ID []byte `gorm:"type:binary(16);primaryKey;column:id"`
|
||||
UserID []byte `gorm:"type:binary(16);uniqueIndex;not null;column:user_id"`
|
||||
SecretEncrypted []byte `gorm:"type:varbinary(512);not null;column:secret_encrypted"`
|
||||
Enabled bool `gorm:"type:tinyint(1);not null;default:0;column:enabled"`
|
||||
LastUsedAt *time.Time `gorm:"column:last_used_at"`
|
||||
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 (UserTOTP) TableName() string { return "user_totp" }
|
||||
|
||||
func (ut *UserTOTP) BeforeCreate(tx *gorm.DB) error {
|
||||
if len(ut.ID) == 0 {
|
||||
ut.ID = uuidv7.MustBytes()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user