diff --git a/src/PdAuth/Middleware/CheckRole.php b/src/PdAuth/Middleware/CheckRole.php index b80a94e..da3f496 100644 --- a/src/PdAuth/Middleware/CheckRole.php +++ b/src/PdAuth/Middleware/CheckRole.php @@ -15,16 +15,15 @@ class CheckRole $roles = $controller::Privileges; if (empty($roles) || empty($roles[$action])) { - api_abort(403, '未定义权限'); + abort(403, '未定义权限'); } $user = $request->user(); - - if (!$user->hasRoles($roles[$action])) { - api_abort(403, '无权访问'); + if (empty(array_intersect($roles[$action],$user['roles']))) { + abort(403, '无权访问'); } return $next($request); } -} \ No newline at end of file +}