From b7fe79208e030831f4a93a7b0334b08dbf9c1fa0 Mon Sep 17 00:00:00 2001 From: he <109787524@qq.com> Date: Fri, 4 Jul 2025 16:47:03 +0800 Subject: [PATCH] =?UTF-8?q?=E7=99=BB=E5=BD=95=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 | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/IRaCIS.Core.Application/Service/Management/UserService.cs b/IRaCIS.Core.Application/Service/Management/UserService.cs index ed843c64e..b2afe6f40 100644 --- a/IRaCIS.Core.Application/Service/Management/UserService.cs +++ b/IRaCIS.Core.Application/Service/Management/UserService.cs @@ -996,11 +996,20 @@ namespace IRaCIS.Core.Application.Service loginUser.NeedChangePassWord = true; } - if (existUserLoginInfo.LastLoginIP != string.Empty) + List userOptTypes = new List() { + UserOptType.Login, + UserOptType.AccountOrPasswordError, + UserOptType.LoginLockedAccount + }; + + var lastLoginIPRegion = await _userLogRepository.Where(t => t.ActionIdentityUserId == existUserLoginInfo.Id && userOptTypes.Contains(t.OptType)) + .OrderByDescending(t => t.CreateTime).Select(t => t.IPRegion).FirstOrDefaultAsync(); + + if (lastLoginIPRegion != string.Empty) { // 与上一次区域不一致 //if (SplitAndConcatenate(existUserLoginInfo.LastLoginIP) != SplitAndConcatenate(iPRegion)) - if (existUserLoginInfo.LastLoginIP != iPRegion) + if (lastLoginIPRegion != iPRegion) { isLoginUncommonly = true;