From 17d22565d26f0ac3d88593b6284142ed01e34b77 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 26 Aug 2024 09:36:15 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BD=BF=E7=94=A8BusinessException?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=E5=A4=84=E7=90=86=E7=99=BB=E5=BD=95=E9=AA=8C?= =?UTF-8?q?=E8=AF=81=E4=B8=AD=E7=9A=84=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/validate/LoginValidate.php | 11 ++++++----- app/common/lists/ListsExcelTrait.php | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/admin/validate/LoginValidate.php b/app/admin/validate/LoginValidate.php index f0ecfcf0c..02dac88a3 100644 --- a/app/admin/validate/LoginValidate.php +++ b/app/admin/validate/LoginValidate.php @@ -10,6 +10,7 @@ use app\common\model\auth\Admin; use app\common\service\ConfigService; use app\common\validate\BaseValidate; use app\MyBusinessException; +use support\exception\BusinessException; use Webman\Config; class LoginValidate extends BaseValidate @@ -54,7 +55,7 @@ class LoginValidate extends BaseValidate //后台账号安全机制,连续输错后锁定,防止账号密码暴力破解 if ($config['login_restrictions'] == 1 && !$adminAccountSafeCache->isSafe()) { - new MyBusinessException('密码连续' . $adminAccountSafeCache->count . '次输入错误,请' . $adminAccountSafeCache->minute . '分钟后重试'); + throw new BusinessException('密码连续' . $adminAccountSafeCache->count . '次输入错误,请' . $adminAccountSafeCache->minute . '分钟后重试'); } $adminInfo = Admin::where('account', '=', $data['account']) @@ -62,21 +63,21 @@ class LoginValidate extends BaseValidate ->findOrEmpty(); if ($adminInfo->isEmpty()) { - return '账号不存在'; + throw new BusinessException('账号不存在'); } if ($adminInfo['disable'] === 1) { - return '账号已禁用'; + throw new BusinessException('账号已禁用'); } if (empty($adminInfo['password'])) { $adminAccountSafeCache->record(); - return '账号不存在'; + throw new BusinessException('账号不存在'); } $passwordSalt = Config::get('project.unique_identification'); if ($adminInfo['password'] !== create_password($password, $passwordSalt)) { $adminAccountSafeCache->record(); - return '密码错误'; + throw new BusinessException('密码错误'); } $adminAccountSafeCache->relieve(); diff --git a/app/common/lists/ListsExcelTrait.php b/app/common/lists/ListsExcelTrait.php index 2397c012e..bf2dcfaa8 100644 --- a/app/common/lists/ListsExcelTrait.php +++ b/app/common/lists/ListsExcelTrait.php @@ -92,7 +92,7 @@ trait ListsExcelTrait } $writer->save($src . $this->fileName); //设置本地excel缓存并返回下载地址 - return 'https://'.request()->host().'/admin/download/export?file='.$exportCache->setFile($this->fileName); + return getenv('APP_URL').'/admin/download/export?file='.$exportCache->setFile($this->fileName); } /** * @notes 获取导出信息