init push
This commit is contained in:
30
internal/domain/auth/webauthn_credential.go
Normal file
30
internal/domain/auth/webauthn_credential.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package auth
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
|
||||
"wucher/internal/shared/pkg/uuidv7"
|
||||
)
|
||||
|
||||
// UserWebAuthnCredential stores a passkey credential bound to a user.
|
||||
type UserWebAuthnCredential struct {
|
||||
ID []byte `gorm:"type:binary(16);primaryKey;column:id"`
|
||||
UserID []byte `gorm:"type:binary(16);index;not null;column:user_id"`
|
||||
Name string `gorm:"type:varchar(100);column:name"`
|
||||
CredentialID []byte `gorm:"type:varbinary(512);uniqueIndex;not null;column:credential_id"`
|
||||
CredentialJSON []byte `gorm:"type:mediumblob;not null;column:credential_json"`
|
||||
LastUsedAt *time.Time `gorm:"column:last_used_at"`
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
|
||||
func (UserWebAuthnCredential) TableName() string { return "user_webauthn_credentials" }
|
||||
|
||||
func (c *UserWebAuthnCredential) BeforeCreate(tx *gorm.DB) error {
|
||||
if len(c.ID) == 0 {
|
||||
c.ID = uuidv7.MustBytes()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user