users

package
v0.0.0-...-70bfa02 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const ERROR_CREATE_USER_USERNAME_ALREADY_TAKEN = "Username already taken"
View Source
const ERROR_INVALID_USERNAME_OR_PASSWORD = "Invalid username or password"
View Source
const ERROR_PASSWORDS_DO_NOT_MATCH = "Passwords do not match"
View Source
const ERROR_UNKNOWN_USER = "Unknown user"

Variables

This section is empty.

Functions

This section is empty.

Types

type User

type User struct {
	ID       uint32
	Username string
	Password string
	Credits  int32
	// contains filtered or unexported fields
}

Represenation of a Matomat users properties, currently only an ID and the Credits (in currency cents).

func (*User) IsAdmin

func (u *User) IsAdmin() bool

type UserItemsStatsRepoSqlite3

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

func NewUserItemsStatsRepoSqlite3

func NewUserItemsStatsRepoSqlite3(sqlite3DbFilePath string) *UserItemsStatsRepoSqlite3

func (*UserItemsStatsRepoSqlite3) CountConsumption

func (r *UserItemsStatsRepoSqlite3) CountConsumption(userID uint32, itemID uint32, consumed uint32) error

func (*UserItemsStatsRepoSqlite3) Get

type UserItemsStatsRepositoryInterface

type UserItemsStatsRepositoryInterface interface {
	Get(userID uint32) ([]items.ItemStats, error)
	CountConsumption(userID uint32, itemID uint32, consumed uint32) error
}

type UserRepoSqlite3

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

func NewUserRepoSqlite3

func NewUserRepoSqlite3(sqlite3DbFilePath string) *UserRepoSqlite3

func (*UserRepoSqlite3) Delete

func (r *UserRepoSqlite3) Delete(userID uint32) (User, error)

func (*UserRepoSqlite3) Get

func (r *UserRepoSqlite3) Get(userID uint32) (User, error)

func (*UserRepoSqlite3) GetByUsername

func (r *UserRepoSqlite3) GetByUsername(username string) (User, error)

func (*UserRepoSqlite3) List

func (r *UserRepoSqlite3) List() ([]User, error)

func (*UserRepoSqlite3) Save

func (r *UserRepoSqlite3) Save(user User) (User, error)

type UserRepositoryInterface

type UserRepositoryInterface interface {
	Get(id uint32) (User, error)
	GetByUsername(username string) (User, error)
	List() ([]User, error)
	Save(user User) (User, error)
	Delete(id uint32) (User, error)
}

type Users

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

func NewUsers

func NewUsers(userRepo UserRepositoryInterface, passwordHashingCost int) *Users

func (*Users) AdminSet

func (ua *Users) AdminSet(userId uint32) (User, error)

func (*Users) AdminUnset

func (ua *Users) AdminUnset(userId uint32) (User, error)

func (*Users) ChangePassword

func (ua *Users) ChangePassword(userId uint32, oldPassword string, newPassword string, newPasswordRepeat string) (User, error)

func (*Users) CreateUser

func (ua *Users) CreateUser(username string, password string, passwordRepeat string, isAdmin int32) (User, error)

func (*Users) DeleteUser

func (ua *Users) DeleteUser(userID uint32) (User, error)

func (*Users) GetUser

func (ua *Users) GetUser(userId uint32) (User, error)

func (*Users) IsPasswordValid

func (ua *Users) IsPasswordValid(username string, password string) (User, error)

func (*Users) ListUsers

func (ua *Users) ListUsers() ([]User, error)

func (*Users) SetPassword

func (ua *Users) SetPassword(userId uint32, newPassword string, newPasswordRepeat string) (User, error)

Jump to

Keyboard shortcuts

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