2024-01-06 17:56:32 +00:00
|
|
|
package models
|
|
|
|
|
2024-01-07 07:52:23 +00:00
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"gorm.io/datatypes"
|
|
|
|
)
|
2024-01-06 17:56:32 +00:00
|
|
|
|
|
|
|
type AccountState = int8
|
|
|
|
|
|
|
|
const (
|
|
|
|
PendingAccountState = AccountState(iota)
|
|
|
|
ActiveAccountState
|
|
|
|
)
|
|
|
|
|
|
|
|
type Account struct {
|
|
|
|
BaseModel
|
|
|
|
|
2024-01-07 07:52:23 +00:00
|
|
|
Name string `json:"name" gorm:"uniqueIndex"`
|
|
|
|
Nick string `json:"nick"`
|
|
|
|
State AccountState `json:"state"`
|
2024-01-28 08:17:38 +00:00
|
|
|
Profile AccountProfile `json:"profile"`
|
2024-01-07 07:52:23 +00:00
|
|
|
Session []AuthSession `json:"sessions"`
|
|
|
|
Challenges []AuthChallenge `json:"challenges"`
|
|
|
|
Factors []AuthFactor `json:"factors"`
|
|
|
|
Contacts []AccountContact `json:"contacts"`
|
2024-01-28 08:17:38 +00:00
|
|
|
ConfirmedAt *time.Time `json:"confirmed_at"`
|
2024-01-07 07:52:23 +00:00
|
|
|
Permissions datatypes.JSONType[[]string] `json:"permissions"`
|
2024-01-06 17:56:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type AccountContactType = int8
|
|
|
|
|
|
|
|
const (
|
|
|
|
EmailAccountContact = AccountContactType(iota)
|
|
|
|
)
|
|
|
|
|
|
|
|
type AccountContact struct {
|
|
|
|
BaseModel
|
|
|
|
|
|
|
|
Type int8 `json:"type"`
|
|
|
|
Content string `json:"content" gorm:"uniqueIndex"`
|
|
|
|
IsPublic bool `json:"is_public"`
|
|
|
|
IsPrimary bool `json:"is_primary"`
|
|
|
|
VerifiedAt *time.Time `json:"verified_at"`
|
|
|
|
AccountID uint `json:"account_id"`
|
|
|
|
}
|