lusers

package
v0.0.0-...-7e023e1 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2024 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UserIDLen       = 10
	ErrUserNotFound = lerr.Str("User not found")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrUserAlreadyExists

type ErrUserAlreadyExists string

func (ErrUserAlreadyExists) Error

func (u ErrUserAlreadyExists) Error() string

type Group

type Group struct {
	Name string
	store.Store
}

func (*Group) AddUser

func (g *Group) AddUser(u *User) error

func (*Group) HasUser

func (g *Group) HasUser(u *User) bool

type User

type User struct {
	ID             []byte `json:"-"`
	Name           string
	HashedPassword []byte
	Groups         slice.Slice[string]
}

func (*User) CheckPassword

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

func (*User) In

func (u *User) In(group string) bool

func (*User) OneRequired

func (u *User) OneRequired(groups []string) bool

OneRequired requires that a user be in one of the listed groups. If no groups are listed, the result is true.

func (*User) SetPassword

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

type UserStore

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

func NewUserStore

func NewUserStore(f store.Factory) (*UserStore, error)

func (*UserStore) Create

func (us *UserStore) Create(name, password string) (*User, error)

func (*UserStore) GetByID

func (us *UserStore) GetByID(id []byte) (*User, error)

func (*UserStore) GetByName

func (us *UserStore) GetByName(name string) (*User, error)

func (*UserStore) Group

func (us *UserStore) Group(name string) (*Group, error)

Group will return a group with the provided name. If one does not already exist, it will be created.

func (*UserStore) Groups

func (us *UserStore) Groups() []string

func (*UserStore) HasGroup

func (us *UserStore) HasGroup(name string) *Group

HasGroup will return a group with the given name only if one already exists.

func (*UserStore) List

func (us *UserStore) List() []string

func (*UserStore) Login

func (us *UserStore) Login(name, password string) (*User, error)

func (*UserStore) Update

func (us *UserStore) Update(u *User) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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