You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.2 KiB
59 lines
1.2 KiB
4 years ago
|
<?php
|
||
|
namespace app\common\adapter;
|
||
|
use com\HonrayAuth;
|
||
|
class AuthAdapter
|
||
|
{
|
||
|
private static $_instance;
|
||
|
|
||
|
/**
|
||
|
* 验证码
|
||
|
* @var string
|
||
|
*/
|
||
|
private $auth_key;
|
||
|
|
||
|
public function __construct($auth_key)
|
||
|
{
|
||
|
$this->auth_key = $auth_key;
|
||
|
}
|
||
|
|
||
|
//实例化权限类
|
||
|
public static function getInstance($auth_key)
|
||
|
{
|
||
|
if (!(self::$_instance instanceof HonrayAuth)) {
|
||
|
self::$_instance = new HonrayAuth($auth_key);
|
||
|
}
|
||
|
return self::$_instance;
|
||
|
}
|
||
|
//登录认证
|
||
|
public function checkLogin($names, $uid, $relation='or')
|
||
|
{
|
||
|
self::getInstance($this->auth_key)->_config['AUTH_TYPE'] = 2;
|
||
|
if ($uid == 1){
|
||
|
return true;
|
||
|
}
|
||
|
if (!self::getInstance($this->auth_key)->check($names, $uid, $relation)) {
|
||
|
return false;
|
||
|
} else {
|
||
|
return true;
|
||
|
}
|
||
|
}
|
||
|
//实时认证
|
||
|
public function checkIntime($names, $uid, $relation='or')
|
||
|
{
|
||
|
self::getInstance($this->auth_key)->_config['AUTH_TYPE'] = 1;
|
||
|
if ($uid == 1) {
|
||
|
return true;
|
||
|
}
|
||
|
if (!self::getInstance($this->auth_key)->check($names, $uid, $relation)) {
|
||
|
return false;
|
||
|
} else {
|
||
|
return true;
|
||
|
}
|
||
|
}
|
||
|
//更新缓存auth_list
|
||
|
public function updateCacheAuth()
|
||
|
{
|
||
|
$res = self::getInstance($this->auth_key)->updateCacheAuth();
|
||
|
return $res;
|
||
|
}
|
||
|
}
|