tomluser

package
v0.0.0-...-be25ffa Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2021 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DirectiveFactory = func(loader func(v interface{}) error) (usersystem.Directive, error) {
	c := &Config{}
	err := loader(c)

	if err != nil {
		return nil, err
	}

	return c, nil
}

Functions

func Flush

func Flush()

func Hash

func Hash(mode string, password string, user *User) (string, error)

Types

type Config

type Config struct {
	Source        statictoml.Source
	Example       statictoml.Source
	ProfileFields []string
	ServePassword bool
	ServeStatus   bool
	ServeAccounts bool
	ServeRoles    bool
	ServeTerm     bool
	ServeProfile  bool
	HashMode      string
}

func (*Config) Execute

func (c *Config) Execute(s *usersystem.UserSystem) error

func (*Config) Load

func (c *Config) Load() (*Users, error)

type Data

type Data struct {
	Users []*User
}

func NewData

func NewData() *Data

type User

type User struct {
	UID      string
	Password string
	HashMode string
	Salt     string
	Accounts []*user.Account
	Banned   bool
	Roles    *role.Roles
	Term     string
	Profiles *profile.Profile
}

func NewUser

func NewUser() *User

func (*User) Clone

func (u *User) Clone() *User

func (*User) SetTo

func (u *User) SetTo(newuser *User)

func (*User) Status

func (u *User) Status() status.Status

func (*User) UpdatePassword

func (u *User) UpdatePassword(hashmode string, password string) error

func (*User) VerifyPassword

func (u *User) VerifyPassword(password string) (bool, error)

type Users

type Users struct {
	Source statictoml.Source

	HashMode string
	status.Service
	ProfileFields map[string]bool
	// contains filtered or unexported fields
}

func NewUsers

func NewUsers() *Users

func (*Users) GetAllUsers

func (u *Users) GetAllUsers() *Data

func (*Users) MustAccountToUID

func (u *Users) MustAccountToUID(account *user.Account) (uid string)

AccountToUID query uid by user account. Return user id . Return empty string as userid if account not found.

func (*Users) MustAccounts

func (u *Users) MustAccounts(uid string) *user.Accounts

func (*Users) MustBindAccount

func (u *Users) MustBindAccount(uid string, account *user.Account)

BindAccount bind account to user. If account exists,user.ErrAccountBindingExists should be rasied.

func (*Users) MustCreateStatus

func (u *Users) MustCreateStatus(uid string)

func (*Users) MustCurrentTerm

func (u *Users) MustCurrentTerm(uid string) string

func (*Users) MustGetProfile

func (u *Users) MustGetProfile(id string) *profile.Profile

func (*Users) MustListUsersByStatus

func (u *Users) MustListUsersByStatus(last string, limit int, reverse bool, statuses ...status.Status) []string

func (*Users) MustLoadStatus

func (u *Users) MustLoadStatus(id string) (status.Status, bool)

func (*Users) MustRemoveStatus

func (u *Users) MustRemoveStatus(uid string)

func (*Users) MustRoles

func (u *Users) MustRoles(uid string) *role.Roles

func (*Users) MustStartNewTerm

func (u *Users) MustStartNewTerm(uid string) string

func (*Users) MustUnbindAccount

func (u *Users) MustUnbindAccount(uid string, account *user.Account)

UnbindAccount unbind account from user. If account not exists,user.ErrAccountUnbindingNotExists should be rasied.

func (*Users) MustUpdatePassword

func (u *Users) MustUpdatePassword(uid string, password string)

UpdatePassword update user password

func (*Users) MustUpdateProfile

func (u *Users) MustUpdateProfile(id string, p *profile.Profile)

func (*Users) MustUpdateStatus

func (u *Users) MustUpdateStatus(uid string, st status.Status)

func (*Users) MustVerifyPassword

func (u *Users) MustVerifyPassword(uid string, password string) bool

MustVerifyPassword Verify user password.

func (*Users) PasswordChangeable

func (u *Users) PasswordChangeable() bool

PasswordChangeable return password changeable

func (*Users) Purge

func (u *Users) Purge(uid string) error

func (*Users) SetRoles

func (u *Users) SetRoles(uid string, r *role.Roles) error

func (*Users) Start

func (u *Users) Start() error

func (*Users) Stop

func (u *Users) Stop() error

Jump to

Keyboard shortcuts

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