mirror of
https://gitee.com/apiadmin/ApiAdmin.git
synced 2025-04-06 03:58:00 +08:00
modified 优化系统后台用户登出
This commit is contained in:
parent
417074d37f
commit
83df90b3ff
@ -15,7 +15,7 @@ class Base extends Controller {
|
|||||||
protected $userInfo;
|
protected $userInfo;
|
||||||
|
|
||||||
public function _initialize() {
|
public function _initialize() {
|
||||||
$ApiAuth = $this->request->get('ApiAuth');
|
$ApiAuth = $this->request->header('ApiAuth');
|
||||||
if ($ApiAuth) {
|
if ($ApiAuth) {
|
||||||
$userInfo = cache($ApiAuth);
|
$userInfo = cache($ApiAuth);
|
||||||
$this->userInfo = json_decode($userInfo, true);
|
$this->userInfo = json_decode($userInfo, true);
|
||||||
|
@ -58,9 +58,9 @@ class Login extends Base {
|
|||||||
} else {
|
} else {
|
||||||
return $this->buildFailed(ReturnCode::LOGIN_ERROR, '用户名密码不正确');
|
return $this->buildFailed(ReturnCode::LOGIN_ERROR, '用户名密码不正确');
|
||||||
}
|
}
|
||||||
$userToken = md5(uniqid() . time());
|
$apiAuth = md5(uniqid() . time());
|
||||||
cache($userToken, json_encode($userInfo), config('apiAdmin.ONLINE_TIME'));
|
cache($apiAuth, json_encode($userInfo), config('apiAdmin.ONLINE_TIME'));
|
||||||
cache($userInfo['id'], $userToken, config('apiAdmin.ONLINE_TIME'));
|
cache($userInfo['id'], $apiAuth, config('apiAdmin.ONLINE_TIME'));
|
||||||
|
|
||||||
$return['access'] = 1000000;
|
$return['access'] = 1000000;
|
||||||
$isSupper = Tools::isAdministrator($userInfo['id']);
|
$isSupper = Tools::isAdministrator($userInfo['id']);
|
||||||
@ -80,16 +80,17 @@ class Login extends Base {
|
|||||||
$return['id'] = $userInfo['id'];
|
$return['id'] = $userInfo['id'];
|
||||||
$return['username'] = $userInfo['username'];
|
$return['username'] = $userInfo['username'];
|
||||||
$return['nickname'] = $userInfo['nickname'];
|
$return['nickname'] = $userInfo['nickname'];
|
||||||
$return['userToken'] = $userToken;
|
$return['apiAuth'] = $apiAuth;
|
||||||
|
|
||||||
return $this->buildSuccess($return, '登录成功');
|
return $this->buildSuccess($return, '登录成功');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function logout() {
|
public function logout() {
|
||||||
cache($this->userInfo, null);
|
$ApiAuth = $this->request->header('ApiAuth');
|
||||||
|
cache($ApiAuth, null);
|
||||||
cache($this->userInfo['id'], null);
|
cache($this->userInfo['id'], null);
|
||||||
|
|
||||||
return $this->buildSuccess(ReturnCode::SUCCESS, [], '登出成功');
|
return $this->buildSuccess([], '登出成功');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user