models

package
v0.0.0-...-bb65b11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 21, 2024 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PasswordAuthFactor = AuthFactorType(iota)
	EmailPasswordFactor
)
View Source
const (
	ActiveChallengeState = AuthChallengeState(iota)
	ExpiredChallengeState
	FinishChallengeState
)
View Source
const (
	ConfirmMagicToken = MagicTokenType(iota)
	RegistrationMagicToken
)
View Source
const (
	EmailAccountContact = AccountContactType(iota)
)
View Source
const (
	NotifySubscriberFirebase = "firebase"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	BaseModel

	Name              string                   `json:"name" gorm:"uniqueIndex"`
	Nick              string                   `json:"nick"`
	Avatar            string                   `json:"avatar"`
	Profile           AccountProfile           `json:"profile"`
	Sessions          []AuthSession            `json:"sessions"`
	Challenges        []AuthChallenge          `json:"challenges"`
	Factors           []AuthFactor             `json:"factors"`
	Contacts          []AccountContact         `json:"contacts"`
	Events            []ActionEvent            `json:"events"`
	MagicTokens       []MagicToken             `json:"-" gorm:"foreignKey:AssignTo"`
	ThirdClients      []ThirdClient            `json:"clients"`
	Notifications     []Notification           `json:"notifications" gorm:"foreignKey:RecipientID"`
	NotifySubscribers []NotificationSubscriber `json:"notify_subscribers"`
	ConfirmedAt       *time.Time               `json:"confirmed_at"`
	PowerLevel        int                      `json:"power_level"`
}

func (Account) GetAvatarPath

func (v Account) GetAvatarPath() string

func (Account) GetPrimaryEmail

func (v Account) GetPrimaryEmail() AccountContact

type AccountContact

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"`
}

type AccountContactType

type AccountContactType = int8

type AccountProfile

type AccountProfile struct {
	BaseModel

	FirstName  string     `json:"first_name"`
	MiddleName string     `json:"middle_name"`
	LastName   string     `json:"last_name"`
	Experience uint64     `json:"experience"`
	Birthday   *time.Time `json:"birthday"`
	AccountID  uint       `json:"account_id"`
}

type ActionEvent

type ActionEvent struct {
	BaseModel

	Type      string `json:"type"`
	Target    string `json:"target"`
	Location  string `json:"location"`
	IpAddress string `json:"ip_address"`
	UserAgent string `json:"user_agent"`
	AccountID uint   `json:"account_id"`
}

type AuthChallenge

type AuthChallenge struct {
	BaseModel

	Location         string                     `json:"location"`
	IpAddress        string                     `json:"ip_address"`
	UserAgent        string                     `json:"user_agent"`
	RiskLevel        int                        `json:"risk_level"`
	Progress         int                        `json:"progress"`
	Requirements     int                        `json:"requirements"`
	BlacklistFactors datatypes.JSONType[[]uint] `json:"blacklist_factors"`
	State            int8                       `json:"state"`
	ExpiredAt        time.Time                  `json:"expired_at"`
	SessionID        *uint                      `json:"session_id"`
	AccountID        uint                       `json:"account_id"`
}

func (AuthChallenge) IsAvailable

func (v AuthChallenge) IsAvailable() error

type AuthChallengeState

type AuthChallengeState = int8

type AuthFactor

type AuthFactor struct {
	BaseModel

	Type      int8    `json:"type"`
	Secret    string  `json:"-"`
	Config    JSONMap `json:"config"`
	AccountID uint    `json:"account_id"`
}

type AuthFactorType

type AuthFactorType = int8

type AuthSession

type AuthSession struct {
	BaseModel

	Claims       datatypes.JSONSlice[string] `json:"claims"`
	Audiences    datatypes.JSONSlice[string] `json:"audiences"`
	Challenge    AuthChallenge               `json:"challenge" gorm:"foreignKey:SessionID"`
	GrantToken   string                      `json:"grant_token"`
	AccessToken  string                      `json:"access_token"`
	RefreshToken string                      `json:"refresh_token"`
	ExpiredAt    *time.Time                  `json:"expired_at"`
	AvailableAt  *time.Time                  `json:"available_at"`
	LastGrantAt  *time.Time                  `json:"last_grant_at"`
	ClientID     *uint                       `json:"client_id"`
	AccountID    uint                        `json:"account_id"`
}

func (AuthSession) IsAvailable

func (v AuthSession) IsAvailable() error

type BaseModel

type BaseModel struct {
	ID        uint           `json:"id" gorm:"primaryKey"`
	CreatedAt time.Time      `json:"created_at"`
	UpdatedAt time.Time      `json:"updated_at"`
	DeletedAt gorm.DeletedAt `json:"deleted_at" gorm:"index"`
}

type JSONMap

type JSONMap = datatypes.JSONType[map[string]any]

type MagicToken

type MagicToken struct {
	BaseModel

	Code      string     `json:"code"`
	Type      int8       `json:"type"`
	AssignTo  *uint      `json:"assign_to"`
	ExpiredAt *time.Time `json:"expired_at"`
}

type MagicTokenType

type MagicTokenType = int8

type Notification

type Notification struct {
	BaseModel

	Subject     string                                `json:"subject"`
	Content     string                                `json:"content"`
	Links       datatypes.JSONSlice[NotificationLink] `json:"links"`
	IsImportant bool                                  `json:"is_important"`
	ReadAt      *time.Time                            `json:"read_at"`
	SenderID    *uint                                 `json:"sender_id"`
	RecipientID uint                                  `json:"recipient_id"`
}
type NotificationLink struct {
	Label string `json:"label"`
	Url   string `json:"url"`
}

NotificationLink Used to embed into notify and render actions

type NotificationSubscriber

type NotificationSubscriber struct {
	BaseModel

	UserAgent string `json:"user_agent"`
	Provider  string `json:"provider"`
	DeviceID  string `json:"device_id" gorm:"uniqueIndex"`
	AccountID uint   `json:"account_id"`
}

type ThirdClient

type ThirdClient struct {
	BaseModel

	Alias         string                      `json:"alias" gorm:"uniqueIndex"`
	Name          string                      `json:"name"`
	Description   string                      `json:"description"`
	Secret        string                      `json:"secret"`
	Urls          datatypes.JSONSlice[string] `json:"urls"`
	Callbacks     datatypes.JSONSlice[string] `json:"callbacks"`
	Sessions      []AuthSession               `json:"sessions" gorm:"foreignKey:ClientID"`
	Notifications []Notification              `json:"notifications" gorm:"foreignKey:SenderID"`
	IsDraft       bool                        `json:"is_draft"`
	AccountID     *uint                       `json:"account_id"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL