权限校验

This commit is contained in:
候学杰 2018-05-03 11:22:14 +08:00
parent 24f08057f8
commit 00cfb2c7c3

View File

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