users

package
v0.0.0-...-edeb3c3 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrHIDChanged = errors.New("HID is not allowed to be changed")
View Source
var ErrUserNotFound = errors.New("user not found")

TODO: bcrypt has a size limit of 72 bytes for the password. This should be checked and handled. Otherwise, switch to argon2id, and save the salt along with the hash in the table.

View Source
var ErrWrongPassword = errors.New("wrong password")

Functions

This section is empty.

Types

type User

type User struct {
	models.Record
	ID       int64          `db:"pk,id"`
	Name     string         `db:"name"`
	Email    string         `db:"email"`
	Password string         `db:"password"`
	UserData types.JsonMap  `db:"user_data"`
	Avatar   string         `db:"avatar"`
	Expires  types.DateTime `db:"expires"`
	LastSeen types.DateTime `db:"last_seen"`
	Role     int            `db:"role"`
	Active   bool           `db:"active"`
	Verified bool           `db:"verified"`
}

func (User) PrimaryKey

func (s User) PrimaryKey() string

func (User) TableName

func (u User) TableName() string

type UserManager

type UserManager struct {
	// contains filtered or unexported fields
}

func New

func New(db *db.DB, tablename, idfield string, user_exp int, lcg_seed uint64) (*UserManager, error)

func (*UserManager) CheckGetUser

func (s *UserManager) CheckGetUser(email string, pw string) (*User, error)

func (*UserManager) CheckPassword

func (s *UserManager) CheckPassword(user *User, pw string) error

TODO: Implement peppering of passwords So hackers cant't do anything if the table is stolen but the process space is intact

func (*UserManager) Count

func (s *UserManager) Count() (int, error)

func (*UserManager) Delete

func (s *UserManager) Delete(id int64) error

func (*UserManager) HasAdmins

func (s *UserManager) HasAdmins() (bool, error)

func (*UserManager) Insert

func (s *UserManager) Insert(user *User, pw string) (*User, error)

func (*UserManager) Select

func (s *UserManager) Select(id int64) (*User, error)

func (*UserManager) SelectByEmail

func (s *UserManager) SelectByEmail(email string) (*User, error)

func (*UserManager) Update

func (s *UserManager) Update(user *User) error

Jump to

Keyboard shortcuts

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