\php4worldAuth

ThinkPHP5.1.* Auth权限认证类 数据表说明: 建表语句在本类同级的tables.sql文件。 建表时根据自身需要删除或替换[php4world_]表前缀

用户与用户组关系[auth_group_access] 用户组列表[auth_group] 规则表[auth_rule]

认证类说明: 1、本类对规则认证,可以把节点(路由)理解为规则实现节点认证。 $auth = new \php4world\Auth(); $auth->check('规则名称', '用户ID');

2、同时对多条规则进行认证,可以设置多条规则的关系[or|and]
   $auth = new \php4world\Auth();
   $auth->check('规则1,规则2,...', '用户ID', 'and');
   -> and表示用户需要同时具有规则列表权限。
   -> or 表示用户只需要具有任一规则权限。

3、规则表达式用法
   在[auth_rule]表中[condition]字段,如果定义了表达式,则同时进行表达式验证。
   比如 {score}>5 and {score}<100 表示用户分数在5~100之间时才会通过认证。
   [score]为用户表字段,表达式字段用{}包裹。

配置说明: 1、正式开发需要在应用配置目录添加根为auth的配置项,参考下面$_config属性 2、配置参数表明根据自己的表名修改

Summary

Methods
Properties
Constants
__construct()
check()
getGroups()
No public properties found
No constants found
getAuthList()
getUserInfo()
$_config
N/A
No private methods found
No private properties found
N/A

Properties

$_config

$_config : 

Type

Methods

__construct()

__construct() 

check()

check(mixed  $name, integer  $uid, string  $relation = 'or', string  $mode = 'url') : boolean

验证权限

Parameters

mixed $name

规则验证列表支持逗号分隔或者数组

integer $uid

用户ID

string $relation

关系类型 or | and

string $mode

执行模式 url

Returns

boolean —

验证结果

getGroups()

getGroups(integer  $uid) : array

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

Parameters

integer $uid

用户ID

Returns

array —

用户所属用户组 ['uid'=>'用户ID', 'group_id'=>'用户组ID', 'title'=>'用户组名', 'rules'=>'用户组拥有的规则ID,多个用英文,隔开']

getAuthList()

getAuthList(integer  $uid) : array

获得权限列表

Parameters

integer $uid

用户ID

Returns

array —

权限列表

getUserInfo()

getUserInfo(  $uid) 

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

Parameters

$uid