model

package
v0.0.0-...-a510100 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VerificationPending = "pending"
	VerificationSent    = "sent"
	VerificationError   = "error"
	EmailVerified       = "verified"

	// TODO: Should moved to configuration database
	TokenExpDuration = 24 // hours
)
View Source
const (
	SessionExpDuration = 1 // hours
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	ID          uint    `gorm:"column:user_id; primaryKey"`
	UserName    *string `gorm:"size:100"`
	Gender      *string `gorm:"size:1"`
	DateOfBirth time.Time
	RoleID      uint
	Role        Role
	BaseModel
}

func (Account) TableName

func (Account) TableName() string

type BaseModel

type BaseModel struct {
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt gorm.DeletedAt `gorm:"index"`
}

type EmailVerification

type EmailVerification struct {
	ID        uint      `gorm:"column:email_verification_id; primaryKey"`
	Status    string    `gorm:"size:50; default:pending"`
	Token     string    `gorm:"column:verification_token; size:100; unique"`
	ExpiredAt time.Time `gorm:"column:token_expiration"`
	BaseModel
}

func (*EmailVerification) BeforeCreate

func (e *EmailVerification) BeforeCreate(tx *gorm.DB) (err error)

func (*EmailVerification) BeforeSave

func (e *EmailVerification) BeforeSave(tx *gorm.DB) (err error)

func (EmailVerification) TableName

func (EmailVerification) TableName() string

type ExternalProvider

type ExternalProvider struct {
	ID   uint   `gorm:"column:external_provider_id; primaryKey"`
	Name string `gorm:"column:provider_name; size:50; unique"`
	Url  string `gorm:"column:web_service_url"`
	BaseModel
}

type HashAlgorithm

type HashAlgorithm struct {
	ID   uint   `gorm:"column:hash_algorithm_id; primaryKey"`
	Name string `gorm:"column:algorithm_name; size:20; unique"`
	BaseModel
}

type LoginExternal

type LoginExternal struct {
	ID         uint             `gorm:"column:user_id; primaryKey"`
	ProviderID uint             `gorm:"column:external_provider_id"`
	Provider   ExternalProvider `gorm:"foreignKey:ProviderID; references:ID"`
	Token      string           `gorm:"column:provider_token; size:100"`
	BaseModel
}

type LoginInfo

type LoginInfo struct {
	ID                  uint   `gorm:"column:user_id; primaryKey"`
	Username            string `gorm:"size:20; unique"`
	Email               string `gorm:"size:100; unique"`
	PasswordHash        string `gorm:"size:250"`
	PasswordSalt        string `gorm:"size:100"`
	HashAlgorithmID     uint
	HashAlgorithm       HashAlgorithm `gorm:"foreignKey:HashAlgorithmID; references:ID"`
	EmailVerificationID uint
	EmailVerification   EmailVerification `gorm:"foreignKey:EmailVerificationID; references:ID"`
	PasswordRecoveryID  *uint
	PasswordRecovery    PasswordRecovery `gorm:"foreignKey:PasswordRecoveryID; references:ID"`
	BaseModel
}

func (*LoginInfo) BeforeCreate

func (i *LoginInfo) BeforeCreate(tx *gorm.DB) (err error)

func (*LoginInfo) BeforeUpdate

func (i *LoginInfo) BeforeUpdate(tx *gorm.DB) (err error)

func (LoginInfo) TableName

func (LoginInfo) TableName() string

type PasswordRecovery

type PasswordRecovery struct {
	ID        uint      `gorm:"column:password_recovery_id; primaryKey"`
	Token     string    `gorm:"column:recovery_token; size:100"`
	ExpiredAt time.Time `gorm:"column:token_expiration"`
	BaseModel
}

func (PasswordRecovery) TableName

func (PasswordRecovery) TableName() string

type Permission

type Permission struct {
	ID   uint   `gorm:"column:permission_id; primaryKey"`
	Name string `gorm:"column:permission_name; size:50"`
	BaseModel
}

type Role

type Role struct {
	ID          uint         `gorm:"column:role_id; primaryKey"`
	Name        string       `gorm:"column:role_name; size:20"`
	Permissions []Permission `` /* 126-byte string literal not displayed */
	BaseModel
}

func (Role) TableName

func (Role) TableName() string

type Session

type Session struct {
	ID        uint `gorm:"column:session_id; primaryKey"`
	UserID    uint
	User      Account
	Token     string    `gorm:"column:session_token; size:100; unique"`
	ExpiredAt time.Time `gorm:"column:session_expiration"`
	BaseModel
}

func (*Session) BeforeCreate

func (s *Session) BeforeCreate(tx *gorm.DB) (err error)

func (Session) TableName

func (Session) TableName() string

Jump to

Keyboard shortcuts

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