model

package
v0.0.0-...-e74fef0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppConfig

type AppConfig struct {
	Encryption Encryption
	Jwt        JwtConfig
	Auth       AuthConfig
}

Reusable config goes here

type AuthConfig

type AuthConfig struct {
	ExcludedMethods []string
}

type Claims

type Claims struct {
	UserId      uint64             `json:"user_id"`
	Name        string             `json:"name"`
	Username    string             `json:"username"`
	Email       string             `json:"email"`
	PhoneNumber string             `json:"phone_number"`
	Roles       []string           `json:"roles"`
	TokenType   constant.TokenType `json:"token_type"`
	jwt.RegisteredClaims
}

type DeviceInfo

type DeviceInfo struct {
	Id     string
	Name   string
	Model  string
	OSInfo OSInfo
}

type Encryption

type Encryption struct {
	Cost           uint8
	MasterPassword string `mapstructure:"mp"`
}

type IsUserExistRequest

type IsUserExistRequest struct {
	Username    string
	Email       string
	PhoneNumber string
}

type IsUserExistResponse

type IsUserExistResponse struct {
	IsExist bool
	Reasons []string
}

type JwtConfig

type JwtConfig struct {
	SigningKey string
	Iss        string
	Exp        string
}

type LoginRequest

type LoginRequest struct {
	UserId      string
	Password    string
	LoginMethod constant.LoginMethod
	DeviceInfo  DeviceInfo
}

func (*LoginRequest) ToUserDevice

func (l *LoginRequest) ToUserDevice(userId uint64) *UserDevice

type LoginResponse

type LoginResponse struct {
	Token    Token
	DeviceId string
}

type OSInfo

type OSInfo struct {
	Name    string
	Version string
}

type RegisterRequest

type RegisterRequest struct {
	Name string

	Email       string
	PhoneNumber string
	Username    string

	PlainPassword  string
	UserPassword   string
	MasterPassword string
}

func (*RegisterRequest) ToUser

func (r *RegisterRequest) ToUser() *User

type RegisterResponse

type RegisterResponse struct {
	StatusCode int
	Reasons    []string
}

type Timestamp

type Timestamp struct {
	CreatedAt time.Time
	UpdatedAt sql.NullTime
	DeletedAt sql.NullTime
}

type Token

type Token struct {
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
}

func (Token) MarshalBinary

func (t Token) MarshalBinary() ([]byte, error)

MarshalBinary fulfills encoding.BinaryMarshaler implementation.

type User

type User struct {
	Id          uint64         `db:"id"`
	Name        string         `db:"name"`
	Email       string         `db:"email"`
	Username    sql.NullString `db:"username"`
	PhoneNumber sql.NullString `db:"phone_number"`

	Password       string `db:"password"`
	MasterPassword string `db:"master_password"`

	IsBlocked bool `db:"is_blocked"`
	Roles     []string

	Timestamp
}

type UserDevice

type UserDevice struct {
	Id          uint64    `db:"id"`
	UserId      uint64    `db:"user_id"`
	DeviceId    string    `db:"device_id"`
	DeviceName  string    `db:"device_name"`
	DeviceModel string    `db:"device_model"`
	OSName      string    `db:"os_name"`
	OSVersion   string    `db:"os_version"`
	LastLogin   time.Time `db:"last_login"`
	IsRevoked   bool      `db:"is_revoked"`
}

type UserRole

type UserRole struct {
	Id   uint8
	Name string
}

Jump to

Keyboard shortcuts

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