From dd8e244e64f438516d7c9e247b0bc2a231df91e9 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Mon, 2 Feb 2026 10:25:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=86=E7=A0=81=E8=BF=9E=E7=BB=AD=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E6=AC=A1=E6=95=B0=E5=88=A4=E6=96=AD=E4=BD=8D=E7=BD=AE?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/Management/UserService.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/IRaCIS.Core.Application/Service/Management/UserService.cs b/IRaCIS.Core.Application/Service/Management/UserService.cs index 0c0f54c33..82b77e306 100644 --- a/IRaCIS.Core.Application/Service/Management/UserService.cs +++ b/IRaCIS.Core.Application/Service/Management/UserService.cs @@ -1000,14 +1000,6 @@ namespace IRaCIS.Core.Application.Service 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(); @@ -1019,7 +1011,7 @@ namespace IRaCIS.Core.Application.Service var isLoginUncommonly = false; - #region //登录用户是系统用户的时候,就要要记录异地登录 + #region 登录用户是系统用户的时候,就要要记录异地登录 //账号在系统存在 if (isExistAccount || loginUser != null) @@ -1093,6 +1085,14 @@ namespace IRaCIS.Core.Application.Service //错误次数累加 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 _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, ActionUserName = userName, LoginPassword = password, OptType = UserOptType.AccountOrPasswordError, IsLoginUncommonly = isLoginUncommonly }, true);