From 3ec10515fb5615f31b656a2617ada13ae710bfd3 Mon Sep 17 00:00:00 2001 From: wuyanwen Date: Sat, 14 Dec 2019 16:54:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- catchAdmin/permissions/PermissionsMiddleware.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/catchAdmin/permissions/PermissionsMiddleware.php b/catchAdmin/permissions/PermissionsMiddleware.php index 2ef432d..7945647 100644 --- a/catchAdmin/permissions/PermissionsMiddleware.php +++ b/catchAdmin/permissions/PermissionsMiddleware.php @@ -22,9 +22,6 @@ class PermissionsMiddleware */ public function handle(Request $request, \Closure $next) { - if (!$request->user()) { - throw new PermissionForbiddenException('Login is invalid', 10006); - } // toad if (($permission = $this->getPermission($request)) && !in_array($permission->id, $request->user()->getPermissionsBy())) { @@ -38,10 +35,11 @@ class PermissionsMiddleware * * @time 2019年12月12日 * @param $request - * @throws \think\db\exception\DataNotFoundException + * @return array|bool|\think\Model|null * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException - * @return array|bool|\think\Model|null + * @throws PermissionForbiddenException + * @throws \think\db\exception\DataNotFoundException */ protected function getPermission(Request $request) { @@ -56,7 +54,11 @@ class PermissionsMiddleware array_pop($controller); $module = array_pop($controller); - + if ($module != 'login') { + if (!$request->user()) { + throw new PermissionForbiddenException('Login is invalid', 10006); + } + } $permissionMark = sprintf('%s:%s', $controllerName, $action); $permission = Permissions::where('module', $module)->where('permission_mark', $permissionMark)->find();