mirror of
https://gitee.com/apiadmin/ApiAdmin.git
synced 2025-04-06 03:58:00 +08:00
modified 规范缓存前缀,便于缓存管理
This commit is contained in:
parent
6765660167
commit
a029b4f05d
@ -26,8 +26,8 @@ class AdminLog {
|
||||
$header = config('apiAdmin.CROSS_DOMAIN');
|
||||
$request = Request::instance();
|
||||
$route = $request->routeInfo();
|
||||
$userToken = $request->header('ApiAuth', '');
|
||||
$userInfo = cache($userToken);
|
||||
$ApiAuth = $request->header('ApiAuth', '');
|
||||
$userInfo = cache('Login:' . $ApiAuth);
|
||||
$userInfo = json_decode($userInfo, true);
|
||||
$menuInfo = AdminMenu::get(['url' => $route['route']]);
|
||||
|
||||
|
@ -23,7 +23,7 @@ class ApiAuth {
|
||||
$header = config('apiAdmin.CROSS_DOMAIN');
|
||||
$ApiAuth = $request->header('ApiAuth', '');
|
||||
if ($ApiAuth) {
|
||||
$userInfo = cache($ApiAuth);
|
||||
$userInfo = cache('Login:' . $ApiAuth);
|
||||
$userInfo = json_decode($userInfo, true);
|
||||
if (!$userInfo || !isset($userInfo['id'])) {
|
||||
$data = ['code' => ReturnCode::AUTH_ERROR, 'msg' => 'ApiAuth不匹配', 'data' => []];
|
||||
|
@ -30,7 +30,7 @@ class ApiPermission {
|
||||
$route = $request->routeInfo();
|
||||
$header = config('apiAdmin.CROSS_DOMAIN');
|
||||
$ApiAuth = $request->header('ApiAuth', '');
|
||||
$userInfo = cache($ApiAuth);
|
||||
$userInfo = cache('Login:' . $ApiAuth);
|
||||
$userInfo = json_decode($userInfo, true);
|
||||
if (!$this->checkAuth($userInfo['id'], $route['route'])) {
|
||||
$data = ['code' => ReturnCode::INVALID, 'msg' => '非常抱歉,您没有权限怎么做!', 'data' => []];
|
||||
|
@ -17,7 +17,7 @@ class Base extends Controller {
|
||||
public function _initialize() {
|
||||
$ApiAuth = $this->request->header('ApiAuth');
|
||||
if ($ApiAuth) {
|
||||
$userInfo = cache($ApiAuth);
|
||||
$userInfo = cache('Login:' . $ApiAuth);
|
||||
$this->userInfo = json_decode($userInfo, true);
|
||||
}
|
||||
}
|
||||
|
@ -64,8 +64,8 @@ class Login extends Base {
|
||||
return $this->buildFailed(ReturnCode::LOGIN_ERROR, '用户名密码不正确');
|
||||
}
|
||||
$apiAuth = md5(uniqid() . time());
|
||||
cache($apiAuth, json_encode($userInfo), config('apiAdmin.ONLINE_TIME'));
|
||||
cache($userInfo['id'], $apiAuth, config('apiAdmin.ONLINE_TIME'));
|
||||
cache('Login:' . $apiAuth, json_encode($userInfo), config('apiAdmin.ONLINE_TIME'));
|
||||
cache('Login:' . $userInfo['id'], $apiAuth, config('apiAdmin.ONLINE_TIME'));
|
||||
|
||||
$return['access'] = 1000000;
|
||||
$isSupper = Tools::isAdministrator($userInfo['id']);
|
||||
@ -92,8 +92,8 @@ class Login extends Base {
|
||||
|
||||
public function logout() {
|
||||
$ApiAuth = $this->request->header('ApiAuth');
|
||||
cache($ApiAuth, null);
|
||||
cache($this->userInfo['id'], null);
|
||||
cache('Login:' . $ApiAuth, null);
|
||||
cache('Login:' . $this->userInfo['id'], null);
|
||||
|
||||
return $this->buildSuccess([], '登出成功');
|
||||
}
|
||||
|
@ -191,7 +191,7 @@ return [
|
||||
// 缓存保存目录
|
||||
'path' => CACHE_PATH,
|
||||
// 缓存前缀
|
||||
'prefix' => '',
|
||||
'prefix' => 'ApiAdmin:',
|
||||
// 缓存有效期 0表示永久缓存
|
||||
'expire' => 0,
|
||||
],
|
||||
|
Loading…
x
Reference in New Issue
Block a user