update:用户禁用

This commit is contained in:
JaguarJack 2020-08-20 21:02:16 +08:00
parent a7609d9c77
commit b1f5c22c9d

View File

@ -3,9 +3,11 @@ namespace app;
// 应用请求对象类 // 应用请求对象类
use catchAdmin\permissions\model\Users;
use catcher\CatchAuth; use catcher\CatchAuth;
use catcher\Code; use catcher\Code;
use catcher\exceptions\FailedException; use catcher\exceptions\FailedException;
use catcher\exceptions\LoginFailedException;
use thans\jwt\exception\TokenBlacklistException; use thans\jwt\exception\TokenBlacklistException;
use thans\jwt\exception\TokenExpiredException; use thans\jwt\exception\TokenExpiredException;
use thans\jwt\exception\TokenInvalidException; use thans\jwt\exception\TokenInvalidException;
@ -29,6 +31,10 @@ class Request extends \think\Request
try { try {
$user = $this->auth->guard($guard ? : config('catch.auth.default.guard'))->user(); $user = $this->auth->guard($guard ? : config('catch.auth.default.guard'))->user();
if ($user->status == Users::DISABLE) {
throw new LoginFailedException('该用户已被禁用');
}
} catch (\Exception $e) { } catch (\Exception $e) {
if ($e instanceof TokenExpiredException) { if ($e instanceof TokenExpiredException) {
throw new FailedException('token 过期', Code::LOGIN_EXPIRED); throw new FailedException('token 过期', Code::LOGIN_EXPIRED);