Compare commits
2 Commits
fbefd0e045
...
4f4b3cd9c0
Author | SHA1 | Date |
---|---|---|
|
4f4b3cd9c0 | |
|
da98b9a331 |
|
@ -53,6 +53,7 @@ class AccountController
|
|||
'nickname' => $db->nickname,
|
||||
'username' => $db->username,
|
||||
'access_exp' => 2592000,
|
||||
'user_type' => 'admin'
|
||||
];
|
||||
// 如果密码正确,生成 JWT 令牌
|
||||
$token = JwtToken::generateToken($user);
|
||||
|
|
|
@ -60,6 +60,7 @@ class UserController
|
|||
'id' => $user->id,
|
||||
'username' => $user->username,
|
||||
'access_exp' => 2592000,
|
||||
'user_type' => 'user'
|
||||
];
|
||||
// 如果密码正确,生成 JWT 令牌
|
||||
$token = JwtToken::generateToken($tmp);
|
||||
|
|
|
@ -64,10 +64,16 @@ class JwtAuthMiddleware implements MiddlewareInterface
|
|||
try {
|
||||
// 解码 token,返回用户信息
|
||||
$decoded = JwtToken::getExtend($token);
|
||||
$user=User::find($decoded['id']);
|
||||
if($user->status==0){
|
||||
return response('',401,['error' => '用户封禁']);
|
||||
if(!empty($decoded['user_type'])&&$decoded['user_type']=='user'){
|
||||
$user=User::find($decoded['id']);
|
||||
if($user->status==0){
|
||||
return response('',401,['error' => '用户封禁']);
|
||||
}
|
||||
}
|
||||
$user=User::find($decoded['id']);
|
||||
// if($user->status==0){
|
||||
// return response('',401,['error' => '用户封禁']);
|
||||
// }
|
||||
// var_dump($decoded);
|
||||
} catch (\Exception $e) {
|
||||
var_dump($e);
|
||||
|
|
Loading…
Reference in New Issue