modified 基类统一获取用户信息,生效用户登出功能

This commit is contained in:
wangkeji 2018-02-28 17:32:55 +08:00
parent be1162986e
commit ae70ef5e90
3 changed files with 9 additions and 10 deletions

View File

@ -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) {

View File

@ -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, [], '登出成功');
}

View File

@ -9,7 +9,7 @@ return [
],
'Login/logout' => [
'admin/Login/logout',
['method' => 'get']
['method' => 'get', 'after_behavior' => $afterBehavior]
],
'Menu/index' => [
'admin/Menu/index',