From 6b536f4a4f39e557daaa54f5af34c8ee2449962e Mon Sep 17 00:00:00 2001 From: he <109787524@qq.com> Date: Fri, 16 Aug 2024 15:38:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9IP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRaCIS.Core.Application/Service/Management/UserService.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/IRaCIS.Core.Application/Service/Management/UserService.cs b/IRaCIS.Core.Application/Service/Management/UserService.cs index e25cfbfc5..3fe37375c 100644 --- a/IRaCIS.Core.Application/Service/Management/UserService.cs +++ b/IRaCIS.Core.Application/Service/Management/UserService.cs @@ -806,12 +806,14 @@ namespace IRaCIS.Application.Services //登录成功 清除缓存 _cache.Set(cacheKey, 0, TimeSpan.FromMinutes(lockoutMinutes)); + var ipinfo = _searcher.Search(_userInfo.IP); + var iPRegion = string.Join('|', ipinfo.Split('|').TakeLast(3)); if (loginUser.LastLoginIP != string.Empty) { // 与上一次IP不一致 - if (loginUser.LastLoginIP != _userInfo.IP) + if (loginUser.LastLoginIP != iPRegion) { loginUser.LoginState = 2; } @@ -832,9 +834,7 @@ namespace IRaCIS.Application.Services }); } - var ipinfo = _searcher.Search(_userInfo.IP); - - var iPRegion = string.Join('|', ipinfo.Split('|').TakeLast(3)); + await _userRepository.BatchUpdateNoTrackingAsync(x => x.Id == loginUser.Id, x => new User() { LastLoginIP = iPRegion,