✨ Account confirm
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"github.com/samber/lo"
|
||||
"time"
|
||||
|
||||
"gorm.io/datatypes"
|
||||
@ -24,10 +25,18 @@ type Account struct {
|
||||
Challenges []AuthChallenge `json:"challenges"`
|
||||
Factors []AuthFactor `json:"factors"`
|
||||
Contacts []AccountContact `json:"contacts"`
|
||||
MagicTokens []MagicToken `json:"-" gorm:"foreignKey:AssignTo"`
|
||||
ConfirmedAt *time.Time `json:"confirmed_at"`
|
||||
Permissions datatypes.JSONType[[]string] `json:"permissions"`
|
||||
}
|
||||
|
||||
func (v Account) GetPrimaryEmail() AccountContact {
|
||||
val, _ := lo.Find(v.Contacts, func(item AccountContact) bool {
|
||||
return item.Type == EmailAccountContact && item.IsPrimary
|
||||
})
|
||||
return val
|
||||
}
|
||||
|
||||
type AccountContactType = int8
|
||||
|
||||
const (
|
||||
|
@ -18,7 +18,7 @@ type AuthFactor struct {
|
||||
BaseModel
|
||||
|
||||
Type int8 `json:"type"`
|
||||
Secret string `json:"secret"`
|
||||
Secret string `json:"-"`
|
||||
Config JSONMap `json:"config"`
|
||||
AccountID uint `json:"account_id"`
|
||||
}
|
||||
|
19
pkg/models/tokens.go
Normal file
19
pkg/models/tokens.go
Normal file
@ -0,0 +1,19 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
|
||||
type MagicTokenType = int8
|
||||
|
||||
const (
|
||||
ConfirmMagicToken = MagicTokenType(iota)
|
||||
RegistrationMagicToken
|
||||
)
|
||||
|
||||
type MagicToken struct {
|
||||
BaseModel
|
||||
|
||||
Code string `json:"code"`
|
||||
Type int8 `json:"type"`
|
||||
AssignTo *uint `json:"assign_to"`
|
||||
ExpiredAt *time.Time `json:"expired_at"`
|
||||
}
|
Reference in New Issue
Block a user