From 00cfb2c7c32a398ce34e3d97d831ff10edc69c1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=80=99=E5=AD=A6=E6=9D=B0?= Date: Thu, 3 May 2018 11:22:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9D=83=E9=99=90=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/PdAuth/Middleware/CheckRole.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/PdAuth/Middleware/CheckRole.php b/src/PdAuth/Middleware/CheckRole.php index e612462..e8a15d6 100644 --- a/src/PdAuth/Middleware/CheckRole.php +++ b/src/PdAuth/Middleware/CheckRole.php @@ -20,11 +20,15 @@ class CheckRole $user = $request->user(); - if( empty($user) || empty($user['roles']) ){ + if (empty($user) || empty($user['roles'])) { 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, '无权访问,请联系管理员授权'); }