model

package
v0.0.0-...-1928144 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2021 License: MIT Imports: 2 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewModel

func NewModel(db *sqlx.DB) *model

Types

type Database

type Database interface {
	SignupUser(user *User) (err error)
	LoginUser(user *User) (err error)
	UpdateUserProfile(user *User) (err error)
	UpdateUserPassword(user *User) (err error)
	UpdateUserLocale(user *User) (err error)
	GetUser(id uint64) (*User, error)
	GetDetailForUserLogin(email string) (*User, error)
}

type Profile

type Profile struct {
	// User's displayed name
	Name string `json:"name" db:"name"`
	// User profile image
	Avatar string `json:"avatar" db:"avatar"`
}

type TwoFAType

type TwoFAType int
const (
	TwoFATypeNotUsed TwoFAType = iota
	TwoFATypeTOTP
)

type User

type User struct {
	// User Unique ID. Generated by snowflake.
	UserID uint64 `json:"user_id,string" db:"user_id"`
	// Mail Address used to log in to the service.
	Email string `json:"email" db:"email"`
	// password stored with bcrypt salt hash.
	Password string `json:"password" db:"password"`
	// 2FA type set by User.
	// 0 : Password authentication only.
	// 1 : TOTP Authentication.
	TwoFAType TwoFAType `json:"two_fa_type" db:"two_fa_type"`
	// The secret key is saved if 2FA for TOTP Authentication is enabled.
	TotpSecret string `json:"totp_secret,omitempty" db:"totp_secret"`
	// User location settings.
	Locale string `json:"locale" db:"locale"`
	// User role settings.
	// Exists for booking and is not currently in use.
	Role int `json:"role" db:"role"`
	// Date when the user was created.
	CreatedAt string `json:",omitempty", db:"created_at"`
	// Date the user last logged in.
	LastLogin string `json:",omitempty", db:"last_login"`
	// Date when the user was deleted.
	DeletedAt string `json:",omitempty", db:"deleted_at"`
	// Detailed profile of the user.
	Profile Profile `json:"user_profiles", db:"user_profiles"`
}

Jump to

Keyboard shortcuts

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