From 0768392b246b024a6208ab850eb1f5db00699131 Mon Sep 17 00:00:00 2001 From: tokumeikoi Date: Thu, 15 Dec 2022 01:58:01 +0800 Subject: [PATCH] update: install default secure path --- app/Console/Commands/V2boardInstall.php | 4 +++- app/Http/Controllers/Admin/ConfigController.php | 2 +- app/Http/Controllers/Passport/AuthController.php | 2 +- routes/web.php | 4 ++-- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/Console/Commands/V2boardInstall.php b/app/Console/Commands/V2boardInstall.php index 563a8b44..5c4dbf2e 100644 --- a/app/Console/Commands/V2boardInstall.php +++ b/app/Console/Commands/V2boardInstall.php @@ -97,7 +97,9 @@ class V2boardInstall extends Command $this->info('一切就绪'); $this->info("管理员邮箱:{$email}"); $this->info("管理员密码:{$password}"); - $this->info('访问 http(s)://你的站点/admin 进入管理面板,你可以用户中心修改你的密码,请设置安全复杂的密码。'); + + $defaultSecurePath = crc32(config('app.key')); + $this->info("访问 http(s)://你的站点/{$defaultSecurePath} 进入管理面板,你可以用户中心修改你的密码。"); } catch (\Exception $e) { $this->error($e->getMessage()); } diff --git a/app/Http/Controllers/Admin/ConfigController.php b/app/Http/Controllers/Admin/ConfigController.php index c46c75a3..930bf50d 100755 --- a/app/Http/Controllers/Admin/ConfigController.php +++ b/app/Http/Controllers/Admin/ConfigController.php @@ -108,7 +108,7 @@ class ConfigController extends Controller 'register_limit_by_ip_enable' => (int)config('v2board.register_limit_by_ip_enable', 0), 'register_limit_count' => config('v2board.register_limit_count', 3), 'register_limit_expire' => config('v2board.register_limit_expire', 60), - 'secure_path' => config('v2board.secure_path', config('v2board.frontend_admin_path', 'admin')) + 'secure_path' => config('v2board.secure_path', config('v2board.frontend_admin_path', crc32(config('app.key')))) ], 'subscribe' => [ 'plan_change_enable' => (int)config('v2board.plan_change_enable', 1), diff --git a/app/Http/Controllers/Passport/AuthController.php b/app/Http/Controllers/Passport/AuthController.php index 6e5d2920..2d57f92b 100644 --- a/app/Http/Controllers/Passport/AuthController.php +++ b/app/Http/Controllers/Passport/AuthController.php @@ -190,7 +190,7 @@ class AuthController extends Controller $email = $request->input('email'); $password = $request->input('password'); - $passwordErrorCount = (int)Cache::get(CacheKey::get('PASSWORD_ERROR_LIMIT', $email)) || 0; + $passwordErrorCount = (int)Cache::get(CacheKey::get('PASSWORD_ERROR_LIMIT', $email), 0); if ($passwordErrorCount >= 5) { abort(500, __('There are too many password errors, please try again after 30 minutes.')); diff --git a/routes/web.php b/routes/web.php index fc7894c5..1555ce18 100755 --- a/routes/web.php +++ b/routes/web.php @@ -39,7 +39,7 @@ Route::get('/', function (Request $request) { }); //TODO:: 兼容 -Route::get('/' . config('v2board.secure_path', config('v2board.frontend_admin_path', 'admin')), function () { +Route::get('/' . config('v2board.secure_path', config('v2board.frontend_admin_path', crc32(config('app.key')))), function () { return view('admin', [ 'title' => config('v2board.app_name', 'V2Board'), 'theme_sidebar' => config('v2board.frontend_theme_sidebar', 'light'), @@ -48,6 +48,6 @@ Route::get('/' . config('v2board.secure_path', config('v2board.frontend_admin_pa 'background_url' => config('v2board.frontend_background_url'), 'version' => config('app.version'), 'logo' => config('v2board.logo'), - 'secure_path' => config('v2board.secure_path', config('v2board.frontend_admin_path', 'admin')) + 'secure_path' => config('v2board.secure_path', config('v2board.frontend_admin_path', crc32(config('app.key')))) ]); });