users

package
v0.0.0-...-e3263a0 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNameRequired = errors.New("name is required")

	ErrLoginRequire = errors.New("Login is required")

	ErrPasswordRequire = errors.New("Passwords is required and can't be blank")

	ErrPasswordLength = errors.New("Password must have at least 6 characters")
)

Functions

func Delete

func Delete(db *sql.DB, id int64) error

func Insert

func Insert(db *sql.DB, u *User) (id int64, err error)

func SetRoutes

func SetRoutes(r chi.Router, db *sql.DB)

func Update

func Update(db *sql.DB, id int64, u *User) error

Types

type User

type User struct {
	ID         int64     `json:"id"`
	Name       string    `json:"name"`
	Login      string    `json:"login"`
	Password   string    `json:"password"`
	CreatedAt  time.Time `json:"created_at"`
	ModifiedAt time.Time `json:"modified_at"`
	Deleted    bool      `json:"-"`
	LastLogin  time.Time `json:"last_login"`
}

func Authenticate

func Authenticate(login, password string) (*User, error)

func Get

func Get(db *sql.DB, id int64) (*User, error)

func SelectAll

func SelectAll(db *sql.DB) ([]User, error)

func (*User) GetID

func (u *User) GetID() int64

func (*User) GetName

func (u *User) GetName() string

func (*User) SetPassword

func (u *User) SetPassword(password string) error

func (*User) Validate

func (u *User) Validate() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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