From 9266139c259ffc4e2d78939bc8908f5f58ab91e6 Mon Sep 17 00:00:00 2001 From: WispX <1591788658@qq.com> Date: Wed, 18 Mar 2020 14:33:37 +0800 Subject: [PATCH] =?UTF-8?q?:hankey:=20=E6=94=B9=E8=BF=9B=E5=8D=95=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/http/middleware/Initialize.php | 16 ++++++++-------- application/http/middleware/WebAuthenticate.php | 7 +++++++ 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/application/http/middleware/Initialize.php b/application/http/middleware/Initialize.php index de45a949..94913026 100644 --- a/application/http/middleware/Initialize.php +++ b/application/http/middleware/Initialize.php @@ -18,14 +18,14 @@ class Initialize if ($request->controller(true) !== 'install' || $request->action(true) !== 'index') { return redirect(url('install/index')); } - } else { - // 检测封禁IP - $banIp = $this->getConfig('ban_ip'); - if ($banIp) { - $ips = explode(',', str_replace(',', ',', $banIp)); - if (in_array($request->ip(), $ips)) { - throw new HttpResponseException(Response::code(403)); - } + } + + // 检测封禁IP + $banIp = $this->getConfig('ban_ip'); + if ($banIp) { + $ips = explode(',', str_replace(',', ',', $banIp)); + if (in_array($request->ip(), $ips)) { + throw new HttpResponseException(Response::code(403)); } } diff --git a/application/http/middleware/WebAuthenticate.php b/application/http/middleware/WebAuthenticate.php index f029dfd0..e5a6479e 100644 --- a/application/http/middleware/WebAuthenticate.php +++ b/application/http/middleware/WebAuthenticate.php @@ -42,6 +42,13 @@ class WebAuthenticate $request->user = $user; + // 单用户模式下, 只允许访问首页(除了接口) + if (env('system.single_user_mode') && !$user) { + if ($path !== 'index/index') { + return redirect(url('/')); + } + } + return $next($request); } }