sys

package
v0.0.0-...-ccb62fa Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2021 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package sys mananges the users, groups and roles.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidUser   = util.Error("无效的用户")
	ErrInvalidGroup  = util.Error("无效的用户组")
	ErrGroupNotEmpty = util.Error("用户组非空")
	ErrAuthFailed    = util.Error("身份认证失败")
	ErrWeakPassword  = util.Error("密码过于简单")
)

Errors.

View Source
var (
	Root = filepath.Join(util.Root, moduleKey)
)

Config options.

Functions

func AuthUser

func AuthUser(code string, password string) (web.ID, error)

AuthUser authenticates the user.

func GroupLevel

func GroupLevel(root, id web.ID) (int, error)

GroupLevel gets the group level by root.

Types

type Group

type Group struct {
	ID     web.ID
	Parent web.ID
	Name   string
	Extra  map[string]interface{} `json:",omitempty"`
}

Group represents a group.

func GetGroup

func GetGroup(id web.ID, extra bool) (*Group, error)

GetGroup gets the group by id.

func GetGroups

func GetGroups(parent web.ID) ([]*Group, error)

GetGroups gets the groups by parent group id.

func (*Group) Check

func (a *Group) Check() error

Check checks if the group is valid.

type Module

type Module struct {
	web.BaseModule
}

Module represents a module.

func (*Module) Load

func (a *Module) Load(root *ws.Router) (err error)

Load loads the module.

type Token

type Token struct {
	ID    web.ID
	Token []byte `json:",omitempty"`
}

Token represents a user token.

type User

type User struct {
	ID    web.ID
	Group web.ID
	Code  string
	Name  string
	Extra map[string]interface{} `json:",omitempty"`
}

User represents a user.

func FindUser

func FindUser(code string, extra bool) (*User, error)

FindUser finds the user by code.

func GetUser

func GetUser(id web.ID, extra bool) (*User, error)

GetUser gets the user by id.

func GetUsers

func GetUsers(group web.ID) ([]*User, error)

GetUsers gets the users by group id.

func (*User) Check

func (a *User) Check() error

Check checks if the user is valid.

Jump to

Keyboard shortcuts

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