From 26714dbc63f1c6662e59e3f3355a4220abc35be1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=80=99=E5=AD=A6=E6=9D=B0?= Date: Fri, 9 Feb 2018 17:01:48 +0800 Subject: [PATCH] bug fix --- src/PdAuth/Middleware/CheckRole.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) 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 +}