account

package
v0.0.0-...-a5fc328 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnableToValidateUser = errors.New("Unable to validate user")
)

Functions

func DeleteUser

func DeleteUser(username string, soft bool) (err error)

func GetUserCount

func GetUserCount() (count int, err error)

func UpdateUser

func UpdateUser(user User) (err error)

func UsernameExists

func UsernameExists(username string) (bool, error)

Types

type Controller

type Controller struct{}

func (*Controller) GetAccount

func (controller *Controller) GetAccount(c *gin.Context)

type Login

type Login struct {
	Username  string `form:"username" json:"username" binding:"required"`
	Password  string `form:"password" json:"password" binding:"required"`
	TwoFactor string `form:"twoFactor" json:"twoFactor"`
}

type Register

type Register struct {
	Username        string `form:"username" json:"username" binding:"required"`
	Password        string `form:"password" json:"password" binding:"required"`
	PasswordConfirm string `form:"passwordConfirm" json:"passwordConfirm" binding:"required"`
}

type TwoFactor

type TwoFactor struct {
	ID       uint      `gorm:"primary_key" json:"-"`
	UserID   uuid.UUID `gorm:"unique;type:uuid;column:user_id;not null;" json:"-"`
	Active   bool      `json:"active"`
	Secret   *string   `json:"-"`
	LastUsed *int      `json:"-"`
}

func (*TwoFactor) Disable

func (t *TwoFactor) Disable() *TwoFactor

func (*TwoFactor) Enable

func (t *TwoFactor) Enable() *TwoFactor

type User

type User struct {
	ID          uuid.UUID       `gorm:"type:uuid;primary_key;" json:"id"`
	Username    string          `gorm:"unique;not null" json:"username,omitempty"`
	Password    string          `json:"-"`
	Active      bool            `json:"active,omitempty"`
	LastLoginAt *time.Time      `json:"lastlogin_at,omitempty"`
	DeletedAt   *time.Time      `sql:"index" json:"deleted_at,omitempty"`
	CreatedAt   *time.Time      `json:"created_at,omitempty"`
	UpdatedAt   *time.Time      `json:"update_at,omitempty"`
	Addresses   []model.Address `json:"addresses,omitempty"`
	TwoFactor   *TwoFactor      `json:"two_factor,omitempty"`
}

func CreateUser

func CreateUser(username string, password string) (user *User, err error)

func GetUserByClaim

func GetUserByClaim(claimUser User, relationships ...string) (user User, err error)

func GetUserByUsernamePassword

func GetUserByUsernamePassword(username string, password string, relationships ...string) (user User, err error)

func (*User) BeforeCreate

func (user *User) BeforeCreate(scope *gorm.Scope) error

func (*User) TwoFactorActive

func (u *User) TwoFactorActive() bool

func (*User) TwoFactorExists

func (u *User) TwoFactorExists() bool

Jump to

Keyboard shortcuts

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