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\service\ConfigService;
|
||||||
use app\common\validate\BaseValidate;
|
use app\common\validate\BaseValidate;
|
||||||
use app\MyBusinessException;
|
use app\MyBusinessException;
|
||||||
|
use support\exception\BusinessException;
|
||||||
use Webman\Config;
|
use Webman\Config;
|
||||||
|
|
||||||
class LoginValidate extends BaseValidate
|
class LoginValidate extends BaseValidate
|
||||||
@ -54,7 +55,7 @@ class LoginValidate extends BaseValidate
|
|||||||
|
|
||||||
//后台账号安全机制,连续输错后锁定,防止账号密码暴力破解
|
//后台账号安全机制,连续输错后锁定,防止账号密码暴力破解
|
||||||
if ($config['login_restrictions'] == 1 && !$adminAccountSafeCache->isSafe()) {
|
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'])
|
$adminInfo = Admin::where('account', '=', $data['account'])
|
||||||
@ -62,21 +63,21 @@ class LoginValidate extends BaseValidate
|
|||||||
->findOrEmpty();
|
->findOrEmpty();
|
||||||
|
|
||||||
if ($adminInfo->isEmpty()) {
|
if ($adminInfo->isEmpty()) {
|
||||||
return '账号不存在';
|
throw new BusinessException('账号不存在');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($adminInfo['disable'] === 1) {
|
if ($adminInfo['disable'] === 1) {
|
||||||
return '账号已禁用';
|
throw new BusinessException('账号已禁用');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($adminInfo['password'])) {
|
if (empty($adminInfo['password'])) {
|
||||||
$adminAccountSafeCache->record();
|
$adminAccountSafeCache->record();
|
||||||
return '账号不存在';
|
throw new BusinessException('账号不存在');
|
||||||
}
|
}
|
||||||
$passwordSalt = Config::get('project.unique_identification');
|
$passwordSalt = Config::get('project.unique_identification');
|
||||||
if ($adminInfo['password'] !== create_password($password, $passwordSalt)) {
|
if ($adminInfo['password'] !== create_password($password, $passwordSalt)) {
|
||||||
$adminAccountSafeCache->record();
|
$adminAccountSafeCache->record();
|
||||||
return '密码错误';
|
throw new BusinessException('密码错误');
|
||||||
}
|
}
|
||||||
|
|
||||||
$adminAccountSafeCache->relieve();
|
$adminAccountSafeCache->relieve();
|
||||||
|
@ -92,7 +92,7 @@ trait ListsExcelTrait
|
|||||||
}
|
}
|
||||||
$writer->save($src . $this->fileName);
|
$writer->save($src . $this->fileName);
|
||||||
//设置本地excel缓存并返回下载地址
|
//设置本地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 获取导出信息
|
* @notes 获取导出信息
|
||||||
|
Loading…
x
Reference in New Issue
Block a user