mirror of
https://gitee.com/apiadmin/ApiAdmin.git
synced 2025-04-06 03:58:00 +08:00
modified 基类统一获取用户信息,生效用户登出功能
This commit is contained in:
parent
be1162986e
commit
ae70ef5e90
@ -12,9 +12,14 @@ use think\Controller;
|
||||
class Base extends Controller {
|
||||
|
||||
private $debug = [];
|
||||
protected $userInfo;
|
||||
|
||||
public function _initialize() {
|
||||
|
||||
$ApiAuth = $this->request->get('ApiAuth');
|
||||
if ($ApiAuth) {
|
||||
$userInfo = cache($ApiAuth);
|
||||
$this->userInfo = json_decode($userInfo, true);
|
||||
}
|
||||
}
|
||||
|
||||
public function buildSuccess($data, $msg = '操作成功', $code = ReturnCode::SUCCESS) {
|
||||
|
@ -86,14 +86,8 @@ class Login extends Base {
|
||||
}
|
||||
|
||||
public function logout() {
|
||||
$userToken = $this->request->get('userToken');
|
||||
if (!$userToken) {
|
||||
return $this->buildFailed(ReturnCode::NOT_EXISTS, '缺少userToken!');
|
||||
}
|
||||
$userInfo = cache($userToken);
|
||||
$userInfo = json_decode($userInfo, true);
|
||||
cache($userToken, null);
|
||||
cache($userInfo['id'], null);
|
||||
cache($this->userInfo, null);
|
||||
cache($this->userInfo['id'], null);
|
||||
|
||||
return $this->buildSuccess(ReturnCode::SUCCESS, [], '登出成功');
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ return [
|
||||
],
|
||||
'Login/logout' => [
|
||||
'admin/Login/logout',
|
||||
['method' => 'get']
|
||||
['method' => 'get', 'after_behavior' => $afterBehavior]
|
||||
],
|
||||
'Menu/index' => [
|
||||
'admin/Menu/index',
|
||||
|
Loading…
x
Reference in New Issue
Block a user