密码连续错误次数判断位置修改
continuous-integration/drone/push Build is passing Details

Test_IRC_Net8
hang 2026-02-02 10:25:54 +08:00
parent 5d7a083f4a
commit dd8e244e64
1 changed files with 9 additions and 9 deletions

View File

@ -1000,14 +1000,6 @@ namespace IRaCIS.Core.Application.Service
var userLog = new UserLog(); var userLog = new UserLog();
if (failCount >= maxFailures)
{
await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, ActionUserName = userName, LoginPassword = password, OptType = UserOptType.TempLockLogin }, true);
//$"密码连续错误{maxFailures}次,当前账号已被限制登录,请等待 {lockoutMinutes} 分钟后再试。"
throw new BusinessValidationFailedException(_localizer["User_ErrorLimit", maxFailures, lockoutMinutes]);
}
var userLoginReturnModel = new IRCLoginReturnDTO(); var userLoginReturnModel = new IRCLoginReturnDTO();
@ -1019,7 +1011,7 @@ namespace IRaCIS.Core.Application.Service
var isLoginUncommonly = false; var isLoginUncommonly = false;
#region //登录用户是系统用户的时候,就要要记录异地登录 #region 登录用户是系统用户的时候,就要要记录异地登录
//账号在系统存在 //账号在系统存在
if (isExistAccount || loginUser != null) if (isExistAccount || loginUser != null)
@ -1093,6 +1085,14 @@ namespace IRaCIS.Core.Application.Service
//错误次数累加 //错误次数累加
failCount++; failCount++;
if (failCount >= maxFailures)
{
await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, ActionUserName = userName, LoginPassword = password, OptType = UserOptType.TempLockLogin }, true);
//$"密码连续错误{maxFailures}次,当前账号已被限制登录,请等待 {lockoutMinutes} 分钟后再试。"
throw new BusinessValidationFailedException(_localizer["User_ErrorLimit", maxFailures, lockoutMinutes]);
}
await _fusionCache.SetAsync(cacheKey, failCount, TimeSpan.FromMinutes(lockoutMinutes)); await _fusionCache.SetAsync(cacheKey, failCount, TimeSpan.FromMinutes(lockoutMinutes));
await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, ActionUserName = userName, LoginPassword = password, OptType = UserOptType.AccountOrPasswordError, IsLoginUncommonly = isLoginUncommonly }, true); await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, ActionUserName = userName, LoginPassword = password, OptType = UserOptType.AccountOrPasswordError, IsLoginUncommonly = isLoginUncommonly }, true);