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