This commit is contained in:
候学杰 2018-02-09 17:01:48 +08:00
parent b99be29a9d
commit 26714dbc63

View File

@ -15,13 +15,12 @@ class CheckRole
$roles = $controller::Privileges; $roles = $controller::Privileges;
if (empty($roles) || empty($roles[$action])) { if (empty($roles) || empty($roles[$action])) {
api_abort(403, '未定义权限'); abort(403, '未定义权限');
} }
$user = $request->user(); $user = $request->user();
if (empty(array_intersect($roles[$action],$user['roles']))) {
if (!$user->hasRoles($roles[$action])) { abort(403, '无权访问');
api_abort(403, '无权访问');
} }
return $next($request); return $next($request);