区分不同权限错误

This commit is contained in:
候学杰 2018-03-05 10:15:11 +08:00
parent 26714dbc63
commit 4a6ddf2e00

View File

@ -19,10 +19,15 @@ class CheckRole
} }
$user = $request->user(); $user = $request->user();
if (empty(array_intersect($roles[$action],$user['roles']))) {
if( empty($user) || empty($user['roles']) ){
abort(403, '无权访问'); abort(403, '无权访问');
} }
if (empty(array_intersect($roles[$action],$user['roles']))) {
abort(403, '无权访问,请联系管理员授权');
}
return $next($request); return $next($request);
} }