feat: 使用BusinessException异常处理登录验证中的错误
This commit is contained in:
parent
19394d4147
commit
17d22565d2
@ -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();
|
||||
|
@ -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 获取导出信息
|
||||
|
Loading…
x
Reference in New Issue
Block a user