users

package
v0.0.0-...-6cee497 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckPasswordHash

func CheckPasswordHash(password, hash string) error

CheckPasswordHash checks password hash and password from user input

func HashPassword

func HashPassword(password string) (string, error)

HashPassword hashes password from user input

Types

type User

type User struct {
	gorm.Model
	Email    string `gorm:"type:varchar(100);unique_index" json:"email"`
	UserName string `gorm:"size:100;not null" json:"username"`
	Password string `gorm:"size:100;not null" json:"password"`
	Avatar   string `gorm:"size:255" json:"avatar"`
	Status   int64  `json:"status"`
}

User define model

func (*User) BeforeSave

func (u *User) BeforeSave() error

BeforeSave hashes user password

func (*User) DeleteByID

func (u *User) DeleteByID(id int64) (*User, error)

DeleteByID returns a user status false based on id

func (*User) GetAllUsers

func (u *User) GetAllUsers() (*[]User, error)

GetAllUsers returns a list of all the user

func (*User) GetUserByEmail

func (u *User) GetUserByEmail() (*User, error)

GetUserByEmail returns a user based on email

func (*User) GetUserByID

func (u *User) GetUserByID(id int64) (*User, error)

GetUserByID returns a user based on id

func (*User) Prepare

func (u *User) Prepare()

Prepare strips user input of any white spaces

func (*User) SaveUser

func (u *User) SaveUser() (*User, error)

SaveUser adds a user to the database

func (*User) UpdateByID

func (u *User) UpdateByID(id int64, user User) (*User, error)

UpdateByID return updated user

func (*User) Validate

func (u *User) Validate(action string) error

Validate function

Jump to

Keyboard shortcuts

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