From 4a6ddf2e00395674fd5b91610d1e296e42131b53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=80=99=E5=AD=A6=E6=9D=B0?= Date: Mon, 5 Mar 2018 10:15:11 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8C=BA=E5=88=86=E4=B8=8D=E5=90=8C=E6=9D=83?= =?UTF-8?q?=E9=99=90=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/PdAuth/Middleware/CheckRole.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/PdAuth/Middleware/CheckRole.php b/src/PdAuth/Middleware/CheckRole.php index da3f496..e612462 100644 --- a/src/PdAuth/Middleware/CheckRole.php +++ b/src/PdAuth/Middleware/CheckRole.php @@ -19,10 +19,15 @@ class CheckRole } $user = $request->user(); - if (empty(array_intersect($roles[$action],$user['roles']))) { + + if( empty($user) || empty($user['roles']) ){ abort(403, '无权访问'); } + if (empty(array_intersect($roles[$action],$user['roles']))) { + abort(403, '无权访问,请联系管理员授权'); + } + return $next($request); }