💩 改进单用户模式

This commit is contained in:
WispX
2020-03-18 14:33:37 +08:00
parent f8be031d08
commit 9266139c25
2 changed files with 15 additions and 8 deletions
+8 -8
View File
@@ -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));
}
}
@@ -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);
}
}