userstore

package
v0.4.19 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2021 License: LGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AdminRole   = "admin"
	UserRole    = "user"
	VisitorRole = "visitor"
	InitNs      = "usersInit"
	IDsNs       = "ids"
	UsersNs     = "users"
	RoleListNs  = "roleList"
	InitTimeKey = "initTime"
	VisitorID   = uint64(1)
	VisitorName = "visitor"
)

Variables

View Source
var (
	ErrReachedLimit    = errors.New("reached space limit")
	DefaultPreferences = Preferences{
		Bg: &sitestore.BgConfig{
			Url:      "",
			Repeat:   "no-repeat",
			Position: "center",
			Align:    "fixed",
		},
		CSSURL:     "",
		LanPackURL: "",
		Lan:        "en_US",
	}
)

Functions

func IsReachedLimitErr

func IsReachedLimitErr(err error) bool

Types

type IUserStore

type IUserStore interface {
	Init(rootName, rootPwd string) error
	IsInited() bool
	AddUser(user *User) error
	DelUser(id uint64) error
	GetUser(id uint64) (*User, error)
	GetUserByName(name string) (*User, error)
	SetInfo(id uint64, user *User) error
	CanIncrUsed(id uint64, capacity int64) (bool, error)
	SetUsed(id uint64, incr bool, capacity int64) error
	SetPwd(id uint64, pwd string) error
	SetPreferences(id uint64, settings *Preferences) error
	ListUsers() ([]*User, error)
	AddRole(role string) error
	DelRole(role string) error
	ListRoles() (map[string]bool, error)
}

type KVUserStore

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

func NewKVUserStore

func NewKVUserStore(store kvstore.IKVStore) (*KVUserStore, error)

func (*KVUserStore) AddRole

func (us *KVUserStore) AddRole(role string) error

func (*KVUserStore) AddUser

func (us *KVUserStore) AddUser(user *User) error

func (*KVUserStore) CanIncrUsed

func (us *KVUserStore) CanIncrUsed(id uint64, capacity int64) (bool, error)

func (*KVUserStore) DelRole

func (us *KVUserStore) DelRole(role string) error

func (*KVUserStore) DelUser

func (us *KVUserStore) DelUser(id uint64) error

func (*KVUserStore) GetUser

func (us *KVUserStore) GetUser(id uint64) (*User, error)

func (*KVUserStore) GetUserByName

func (us *KVUserStore) GetUserByName(name string) (*User, error)

func (*KVUserStore) Init

func (us *KVUserStore) Init(rootName, rootPwd string) error

func (*KVUserStore) IsInited

func (us *KVUserStore) IsInited() bool

func (*KVUserStore) ListRoles

func (us *KVUserStore) ListRoles() (map[string]bool, error)

func (*KVUserStore) ListUsers

func (us *KVUserStore) ListUsers() ([]*User, error)

func (*KVUserStore) SetInfo

func (us *KVUserStore) SetInfo(id uint64, user *User) error

func (*KVUserStore) SetPreferences added in v0.4.13

func (us *KVUserStore) SetPreferences(id uint64, prefers *Preferences) error

func (*KVUserStore) SetPwd

func (us *KVUserStore) SetPwd(id uint64, pwd string) error

func (*KVUserStore) SetUsed

func (us *KVUserStore) SetUsed(id uint64, incr bool, capacity int64) error

type Preferences added in v0.4.13

type Preferences struct {
	Bg         *sitestore.BgConfig `json:"bg"`
	CSSURL     string              `json:"cssURL"`
	LanPackURL string              `json:"lanPackURL"`
	Lan        string              `json:"lan"`
}

type Quota

type Quota struct {
	SpaceLimit         int64 `json:"spaceLimit,string"`
	UploadSpeedLimit   int   `json:"uploadSpeedLimit"`
	DownloadSpeedLimit int   `json:"downloadSpeedLimit"`
}

type User

type User struct {
	ID          uint64       `json:"id,string"`
	Name        string       `json:"name"`
	Pwd         string       `json:"pwd"`
	Role        string       `json:"role"`
	UsedSpace   int64        `json:"usedSpace,string"`
	Quota       *Quota       `json:"quota"`
	Preferences *Preferences `json:"preferences"`
}

type UserCfg

type UserCfg struct {
	Name string `json:"name"`
	Role string `json:"role"`
	Pwd  string `json:"pwd"`
}

Jump to

Keyboard shortcuts

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