From e78cf5de0edaa077617eb6c23d6924ee4ae80992 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:33:48 +0800 Subject: [PATCH] fix --- src/PdAuth/Middleware/CheckRole.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/PdAuth/Middleware/CheckRole.php b/src/PdAuth/Middleware/CheckRole.php index e8a15d6..549ab4c 100644 --- a/src/PdAuth/Middleware/CheckRole.php +++ b/src/PdAuth/Middleware/CheckRole.php @@ -18,16 +18,16 @@ class CheckRole abort(403, '未定义权限'); } + if (is_string($roles[$action]) && $roles[$action] == '*') { + return $next($request); + } + $user = $request->user(); if (empty($user) || empty($user['roles'])) { abort(403, '无权访问'); } - if (is_string($roles[$action]) && $roles[$action] == '*') { - return $next($request); - } - if (empty(array_intersect($roles[$action], $user['roles']))) { abort(403, '无权访问,请联系管理员授权'); }