增加权限处理
This commit is contained in:
parent
4f4b3cd9c0
commit
74a8c2d512
|
@ -33,6 +33,7 @@ class JwtAuthMiddleware implements MiddlewareInterface
|
||||||
if($controller->name=='hg\apidoc\Controller'){
|
if($controller->name=='hg\apidoc\Controller'){
|
||||||
return $handler($request);
|
return $handler($request);
|
||||||
}
|
}
|
||||||
|
// var_dump($controller->name);
|
||||||
$noNeedLogin = $controller->getDefaultProperties()['noNeedLogin'] ?? [];
|
$noNeedLogin = $controller->getDefaultProperties()['noNeedLogin'] ?? [];
|
||||||
if (in_array($request->action, $noNeedLogin)) {
|
if (in_array($request->action, $noNeedLogin)) {
|
||||||
// 不需要登录的方法继续向洋葱芯穿越
|
// 不需要登录的方法继续向洋葱芯穿越
|
||||||
|
@ -65,6 +66,9 @@ class JwtAuthMiddleware implements MiddlewareInterface
|
||||||
// 解码 token,返回用户信息
|
// 解码 token,返回用户信息
|
||||||
$decoded = JwtToken::getExtend($token);
|
$decoded = JwtToken::getExtend($token);
|
||||||
if(!empty($decoded['user_type'])&&$decoded['user_type']=='user'){
|
if(!empty($decoded['user_type'])&&$decoded['user_type']=='user'){
|
||||||
|
if (false !== strstr($controller->name, 'admin')) {
|
||||||
|
return response('',401,['error' => '无权限']);
|
||||||
|
}
|
||||||
$user=User::find($decoded['id']);
|
$user=User::find($decoded['id']);
|
||||||
if($user->status==0){
|
if($user->status==0){
|
||||||
return response('',401,['error' => '用户封禁']);
|
return response('',401,['error' => '用户封禁']);
|
||||||
|
|
Loading…
Reference in New Issue