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); }