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;