tomluser

package
v0.0.0-...-2c17daf Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2021 License: MIT, MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DirectiveFactory = func(loader func(v interface{}) error) (member.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
	AsPasswordProvider bool
	AsStatusProvider   bool
	AsAccountsProvider bool
	AsRoleProvider     bool
	HashMode           string
}

func (*Config) Execute

func (c *Config) Execute(m *member.Service) 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
}

func NewUser

func NewUser() *User

func (*User) Clone

func (u *User) Clone() *User

func (*User) SetTo

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

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
	// contains filtered or unexported fields
}

func NewUsers

func NewUsers() *Users

func (*Users) AccountToUID

func (u *Users) AccountToUID(account *user.Account) (uid string, err error)

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

func (*Users) AccountToUIDOrRegister

func (u *Users) AccountToUIDOrRegister(account *user.Account) (uid string, registerd bool, err error)

AccountToUIDOrRegister query uid by user account.Register user if account not found. Return user id and any error if raised.

func (*Users) Accounts

func (u *Users) Accounts(uid ...string) (*member.Accounts, error)

Accounts return account map of given uid list. Return account map and any error if raised.

func (*Users) BindAccount

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

BindAccount bind account to user. Return any error if raised. If account exists,user.ErrAccountBindingExists should be rasied.

func (*Users) PasswordChangeable

func (u *Users) PasswordChangeable() bool

PasswordChangeable return password changeable

func (*Users) Register

func (u *Users) Register(account *user.Account) (uid string, err error)

Register create new user with given account. Return created user id and any error if raised. Privoder should return ErrAccountRegisterExists if account is used.

func (*Users) Roles

func (u *Users) Roles(uid ...string) (*member.Roles, error)

Roles return role map of given uid list. Return role map and any error if raised.

func (*Users) SetStatus

func (u *Users) SetStatus(uid string, status member.Status) error

SetStatus set user status. Return any error if raised.

func (*Users) Statuses

func (u *Users) Statuses(uid ...string) (member.StatusMap, error)

Statuses return status map of given uid list. Return status map and any error if raised.

func (*Users) SupportedStatus

func (u *Users) SupportedStatus() map[member.Status]bool

SupportedStatus return supported status map

func (*Users) UnbindAccount

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

UnbindAccount unbind account from user. Return any error if raised. If account not exists,user.ErrAccountUnbindingNotExists should be rasied.

func (*Users) UpdatePassword

func (u *Users) UpdatePassword(uid string, password string) error

UpdatePassword update user password Return any error if raised

func (*Users) VerifyPassword

func (u *Users) VerifyPassword(uid string, password string) (bool, error)

VerifyPassword Verify user password. Return verify result and any error if raised

Jump to

Keyboard shortcuts

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