From 48c28fa97d7f22b7a520eaf66e6e3ef0f28c4353 Mon Sep 17 00:00:00 2001 From: augushong Date: Thu, 8 Dec 2022 21:30:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B8=85=E7=90=86=E6=8A=80=E6=9C=AF=E5=80=BA?= =?UTF-8?q?=E5=8A=A1=EF=BC=8C=E5=88=A0=E9=99=A4=E6=97=A0=E7=94=A8=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/config/route.php | 7 ---- app/admin/middleware.php | 7 ---- app/admin/middleware/CheckAdmin.php | 58 ----------------------------- app/admin/middleware/ViewInit.php | 49 ------------------------ 4 files changed, 121 deletions(-) delete mode 100644 app/admin/middleware/CheckAdmin.php delete mode 100644 app/admin/middleware/ViewInit.php diff --git a/app/admin/config/route.php b/app/admin/config/route.php index f75c439..bfae446 100644 --- a/app/admin/config/route.php +++ b/app/admin/config/route.php @@ -8,12 +8,5 @@ return [ // 路由中间件 'middleware' => [ -// // 后台视图初始化 -// \app\admin\middleware\ViewInit::class, - - // 检测用户是否登录 -// \app\admin\middleware\CheckAdmin::class, - - ], ]; diff --git a/app/admin/middleware.php b/app/admin/middleware.php index 56b6897..bd595d4 100644 --- a/app/admin/middleware.php +++ b/app/admin/middleware.php @@ -11,11 +11,4 @@ return [ // Csrf安全校验 \app\admin\middleware\CsrfMiddleware::class, - // 后台视图初始化 -// \app\admin\middleware\ViewInit::class, - - // 检测用户是否登录 -// \app\admin\middleware\CheckAdmin::class, - - ]; diff --git a/app/admin/middleware/CheckAdmin.php b/app/admin/middleware/CheckAdmin.php deleted file mode 100644 index e6f657d..0000000 --- a/app/admin/middleware/CheckAdmin.php +++ /dev/null @@ -1,58 +0,0 @@ - $adminId]); - $currentNode = $authService->getCurrentNode(); - $currentController = parse_name($request->controller()); - - // 验证登录 - if (!in_array($currentController, $adminConfig['no_login_controller']) && - !in_array($currentNode, $adminConfig['no_login_node'])) { - empty($adminId) && $this->error('请先登录后台', [], __url('admin/login/index')); - - // 判断是否登录过期 - if ($expireTime !== true && time() > $expireTime) { - session('admin', null); - $this->error('登录已过期,请重新登录', [], __url('admin/login/index')); - } - } - - // 验证权限 - if (!in_array($currentController, $adminConfig['no_auth_controller']) && - !in_array($currentNode, $adminConfig['no_auth_node'])) { - $check = $authService->checkNode($currentNode); - !$check && $this->error('无权限访问'); - - // 判断是否为演示环境 - if(env('adminsystem.is_demo', false) && $request->isPost()){ - $this->error('演示环境下不允许修改'); - } - - } - - return $next($request); - } - -} \ No newline at end of file diff --git a/app/admin/middleware/ViewInit.php b/app/admin/middleware/ViewInit.php deleted file mode 100644 index ba9285f..0000000 --- a/app/admin/middleware/ViewInit.php +++ /dev/null @@ -1,49 +0,0 @@ -getName(), Request::controller(), $request->action()]; - list($thisControllerArr, $jsPath) = [explode('.', $thisController), null]; - foreach ($thisControllerArr as $vo) { - empty($jsPath) ? $jsPath = parse_name($vo) : $jsPath .= '/' . parse_name($vo); - } - $autoloadJs = file_exists(root_path('public')."static/{$thisModule}/js/{$jsPath}.js") ? true : false; - $thisControllerJsPath = "{$thisModule}/js/{$jsPath}.js"; - $adminModuleName = config('app.admin_alias_name'); - $isSuperAdmin = session('admin.id') == AdminConstant::SUPER_ADMIN_ID ? true : false; - $data = [ - 'adminModuleName' => $adminModuleName, - 'thisController' => parse_name($thisController), - 'thisAction' => $thisAction, - 'thisRequest' => parse_name("{$thisModule}/{$thisController}/{$thisAction}"), - 'thisControllerJsPath' => "{$thisControllerJsPath}", - 'autoloadJs' => $autoloadJs, - 'isSuperAdmin' => $isSuperAdmin, - 'version' => env('app_debug') ? time() : ConfigService::getVersion(), - ]; - - View::assign($data); - $request->adminModuleName = $adminModuleName; - return $next($request); - } - - -} \ No newline at end of file