💩 改进单用户模式
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user