user

package
v0.0.0-...-b6d6674 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2020 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Controller

type Controller struct {
	Repo RepositoryUsers
}

Controller users

func (*Controller) Get

func (m *Controller) Get(ctx iris.Context)

Get method

type Credentials

type Credentials struct {
	database.BaseModel
	UserID         uuid.UUID `gorm:"index:user_id;column:user_id;type:uuid;not null"`
	Users          Users     `gorm:"association_foreignkey:user_id;foreignkey:id"`
	Type           string    `gorm:"column:type;type:varchar(20);not null"` // 'password','email','phone','sshkey','vendor','fingerprint'
	UserKey        string    `gorm:"column:user_key;type:text"`
	UserValue      string    `gorm:"column:user_value;type:text"`
	Status         string    `gorm:"column:status;type:varchar(20);not null"` // enum('active','inactive','unverified','deleted')
	LastAccessedAt time.Time `gorm:"column:last_accessed_at;type:datetime;not null"`
	Desc           string    `gorm:"column:desc;type:text"`
}

Credentials [...]

type Input

type Input struct {
	Username string `json:"username"`
	Name     string `json:"name"`
	Email    string `json:"email"`
	Password string `json:"password"`
}

Input struct

type Login

type Login struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

Login ...

type RepositoryUser

type RepositoryUser struct {
	DB     *gorm.DB
	Status bool
}

RepositoryUser ...

func NewRepository

func NewRepository(db *gorm.DB) *RepositoryUser

NewRepository ...

func (*RepositoryUser) Authenticate

func (m *RepositoryUser) Authenticate(username string, password string) (Users, string, bool, error)

Authenticate method

func (*RepositoryUser) Create

func (m *RepositoryUser) Create(newUser Input) (Users, bool, error)

Create for a user

func (*RepositoryUser) CreateAdmin

func (m *RepositoryUser) CreateAdmin() (map[string]string, bool, error)

CreateAdmin for the first time only

func (*RepositoryUser) CreateToken

func (m *RepositoryUser) CreateToken(user Users) (string, error)

CreateToken ...

func (*RepositoryUser) Delete

func (m *RepositoryUser) Delete(uuid uuid.UUID)

Delete a user

func (*RepositoryUser) Get

func (m *RepositoryUser) Get() (Users, error)

Get ...

func (*RepositoryUser) GetBy

func (m *RepositoryUser) GetBy(column, value string) (Users, error)

GetBy ...

func (*RepositoryUser) GetByEmail

func (m *RepositoryUser) GetByEmail(email string) (Users, error)

GetByEmail ...

func (*RepositoryUser) GetByID

func (m *RepositoryUser) GetByID(uuid uuid.UUID) (Users, error)

GetByID ...

func (*RepositoryUser) GetByUsername

func (m *RepositoryUser) GetByUsername(username string) (Users, error)

GetByUsername ...

type RepositoryUsers

type RepositoryUsers interface {
	Get() (user Users, err error)
	Authenticate(string, string) (Users, string, bool, error)
	CreateAdmin() (map[string]string, bool, error)
	CreateToken(user Users) (string, error)
	Create(newUser Input) (Users, bool, error)
	Delete(uuid uuid.UUID)
}

RepositoryUsers ...

type Signin

type Signin struct {
	Repo RepositoryUsers
}

Signin controller

func (*Signin) Get

func (m *Signin) Get() interface{}

Get method

func (*Signin) Post

func (m *Signin) Post(ctx iris.Context)

Post method

type Signup

type Signup struct {
	DB *gorm.DB
}

Signup controller

func (*Signup) Get

func (m *Signup) Get() interface{}

Get method

func (*Signup) Post

func (m *Signup) Post(ctx iris.Context)

Post method

type Users

type Users struct {
	database.BaseModel
	Username                    string    `gorm:"unique;column:username;type:varchar(20);not null"`
	Name                        string    `gorm:"column:name;type:varchar(30)"`
	Status                      string    `gorm:"column:status;type:varchar(20);not null"`
	LastLogin                   time.Time `gorm:"column:last_login;type:datetime"`
	VerificationCode            string    `gorm:"unique;column:verification_code;type:varchar(8)"`
	ForgotPasswordCode          string    `gorm:"unique;column:forgot_password_code;type:varchar(8)"`
	ForgotPasswordCodeValidTime time.Time `gorm:"column:forgot_password_code_valid_time;type:datetime"`
}

Users data of struct

Jump to

Keyboard shortcuts

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