entity

package
v0.0.0-...-8357749 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RoleGuestWeight = iota
	RoleUserWeight
	RoleManagerWeight
	RoleAdminWeight

	RoleGuest   = "guest"
	RoleUser    = "user"
	RoleManager = "manager"
	RoleAdmin   = "admin"
)
View Source
const (
	TokenClassCode    = "code"
	TokenClassAccess  = "access"
	TokenClassRefresh = "refresh"
	TokenClassForgot  = "forgot"

	TokenCodeCost    = 50
	TokenRefreshCost = 100

	TokenCodeTTL    = time.Minute
	TokenAccessTTL  = time.Minute * 2
	TokenRefreshTTL = time.Hour * 24 * 30
)
View Source
const (
	PayloadQuery = "query"
)

Variables

Functions

This section is empty.

Types

type Client

type Client struct {
	Id        string     `db:"id"`
	Name      string     `db:"name"`
	Icon      *string    `db:"icon"`
	Secret    string     `db:"secret"`
	Callback  string     `db:"callback"`
	IsSystem  bool       `db:"is_system"`
	CreatedAt time.Time  `db:"created_at"`
	UpdatedAt time.Time  `db:"updated_at"`
	DeletedAt *time.Time `db:"deleted_at"`
}

type ClientRole

type ClientRole struct {
	*Client `db:""`
	Role    string
}

type Payload

type Payload map[string]string

func (*Payload) Query

func (p *Payload) Query() string

func (*Payload) Scan

func (p *Payload) Scan(value interface{}) error

func (*Payload) Value

func (p *Payload) Value() (driver.Value, error)

type Role

type Role struct {
	ClientId string `db:"client_id"`
	UserId   string `db:"user_id"`
	Role     string `db:"role"`
}

type Session

type Session struct {
	Id        string    `db:"id"`
	UserId    string    `db:"user_id"`
	Ip        string    `db:"ip"`
	Agent     string    `db:"agent"`
	CreatedAt time.Time `db:"created_at"`
	UpdatedAt time.Time `db:"updated_at"`
}

func (*Session) Parse

func (s *Session) Parse() useragent.UserAgent

type SessionUser

type SessionUser struct {
	*Session
	*User
}

type Token

type Token struct {
	Id         string    `db:"id"`
	Class      string    `db:"class"`
	Hash       string    `db:"hash"`
	SessionId  *string   `db:"session_id"`
	UserId     *string   `db:"user_id"`
	ClientId   *string   `db:"client_id"`
	Payload    Payload   `db:"payload"`
	NotBefore  time.Time `db:"not_before"`
	Expiration time.Time `db:"expiration"`
	CreatedAt  time.Time `db:"created_at"`
	UpdatedAt  time.Time `db:"updated_at"`
}

func (*Token) IsActive

func (e *Token) IsActive() bool

type User

type User struct {
	Id        string     `db:"id"`
	Name      string     `db:"name"`
	Email     string     `db:"email"`
	Password  string     `db:"password"`
	CreatedAt time.Time  `db:"created_at"`
	UpdatedAt time.Time  `db:"updated_at"`
	DeletedAt *time.Time `db:"deleted_at"`
}

Jump to

Keyboard shortcuts

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