\app\admin\serviceUser

权限认证类 功能特性: 1,是对规则进行认证,不是对节点进行认证。用户可以把节点当作规则名称实现对节点进行认证。 $auth=new Auth(); $auth->check('规则名称','用户id') 2,可以同时对多条规则进行认证,并设置多条规则的关系(or或者and) $auth=new Auth(); $auth->check('规则1,规则2','用户id','and') 第三个参数为and时表示,用户需要同时具有规则1和规则2的权限。 当第三个参数为or时,表示用户值需要具备其中一个条件即可。默认为or 3,一个用户可以属于多个用户组(think_auth_group_access表 定义了用户所属用户组)。我们需要设置每个用户组拥有哪些规则(think_auth_group 定义了用户组权限)

4,支持规则表达式。 在think_auth_rule 表中定义一条规则时,如果type为1, condition字段就可以定义规则表达式。 如定义{score}>5 and {score}<100 表示用户的分数在5-100之间时这条规则才会通过。

Summary

Methods
Properties
Constants
__construct()
instance()
check()
getGroups()
getRuleIds()
__get()
getChildrenGroupIds()
getChildrenAdminIds()
login()
autologin()
isLogin()
isAdministrator()
match()
logout()
getError()
setError()
No public properties found
No constants found
getAuthList()
getUserInfo()
keeplogin()
$instance
$request
$_config
$error
$logined
N/A
No private methods found
No private properties found
N/A

Properties

$instance

$instance

$request

$request : \think\facade\Request

当前请求实例

Type

Request

$_config

$_config

$error

$error

$logined

$logined

Methods

__construct()

__construct() : mixed

类架构函数 Auth constructor.

Returns

mixed —

instance()

instance(array  $options = []) : \libs\Auth

初始化

Parameters

array $options

参数

Returns

\libs\Auth —

check()

check(mixed  $name, mixed  $uid, mixed  $type = 1, mixed  $mode = 'url', mixed  $relation = 'or') : bool

检查权限

Parameters

mixed $name
mixed $uid
mixed $type
mixed $mode
mixed $relation

Returns

bool —

通过验证返回true;失败返回false

getGroups()

getGroups(mixed  $uid = null) : array

根据用户id获取用户组,返回值为数组

Parameters

mixed $uid

Returns

array —

用户所属的用户组 array( array('uid'=>'用户id','group_id'=>'用户组id','title'=>'用户组名称','rules'=>'用户组拥有的规则id,多个,号隔开'), ...)

getRuleIds()

getRuleIds(mixed  $uid = null) : mixed

Parameters

mixed $uid

Returns

mixed —

__get()

__get(mixed  $name) : mixed

Parameters

mixed $name

Returns

mixed —

getChildrenGroupIds()

getChildrenGroupIds(bool  $withself = false) : array

取出当前管理员所拥有权限的分组.

Parameters

bool $withself

是否包含当前所在的分组

Returns

array —

getChildrenAdminIds()

getChildrenAdminIds(bool  $withself = false) : array

取出当前管理员所拥有权限的管理员.

Parameters

bool $withself

是否包含自身

Returns

array —

login()

login(string  $username = '', string  $password = '', mixed  $keeptime) : bool|mixed

用户登录

Parameters

string $username

用户名

string $password

密码

mixed $keeptime

Returns

bool|mixed —

autologin()

autologin() : bool

自动登录

Returns

bool —

isLogin()

isLogin() : bool

检验用户是否已经登陆

Returns

bool —

失败返回false,成功返回当前登陆用户基本信息

isAdministrator()

isAdministrator() : bool

检查当前用户是否超级管理员

Returns

bool —

match()

match(array  $arr = [], mixed  $path = "") : bool

检测当前控制器和方法是否匹配传递的数组

Parameters

array $arr

需要验证权限的数组

mixed $path

Returns

bool —

logout()

logout() : mixed

注销登录

Returns

mixed —

getError()

getError() : mixed

获取错误信息

Returns

mixed —

setError()

setError(string  $error) : \app\admin\service\Auth

设置错误信息

Parameters

string $error

错误信息

Returns

\app\admin\service\Auth —

getAuthList()

getAuthList(int  $uid, int  $type) : mixed

获得权限列表

Parameters

int $uid

用户id

int $type

Returns

mixed —

getUserInfo()

getUserInfo(mixed  $uid) : mixed

获得用户资料,根据自己的情况读取数据库

Parameters

mixed $uid

Returns

mixed —

keeplogin()

keeplogin(int  $keeptime) : bool

刷新保持登录的Cookie

Parameters

int $keeptime

Returns

bool —