Merge branch 'Test_IRC_Net8' of http://192.168.3.68:2000/XCKJ/irc-netcore-api into Test_IRC_Net8
continuous-integration/drone/push Build is passing Details

IRC_NewDev
hang 2024-08-16 15:42:13 +08:00
commit ef5ae76907
1 changed files with 9 additions and 3 deletions

View File

@ -18,6 +18,7 @@ using LoginReturnDTO = IRaCIS.Application.Contracts.LoginReturnDTO;
using IRaCIS.Core.Application.Auth; using IRaCIS.Core.Application.Auth;
using IRaCIS.Core.Domain.Models; using IRaCIS.Core.Domain.Models;
using IRaCIS.Core.Application.Helper; using IRaCIS.Core.Application.Helper;
using IP2Region.Net.Abstractions;
namespace IRaCIS.Application.Services namespace IRaCIS.Application.Services
{ {
@ -37,6 +38,7 @@ namespace IRaCIS.Application.Services
private readonly IReadingImageTaskService _readingImageTaskService; private readonly IReadingImageTaskService _readingImageTaskService;
private readonly IOptionsMonitor<ServiceVerifyConfigOption> _verifyConfig; private readonly IOptionsMonitor<ServiceVerifyConfigOption> _verifyConfig;
private readonly SystemEmailSendConfig _systemEmailConfig; private readonly SystemEmailSendConfig _systemEmailConfig;
public ISearcher _searcher;
public UserService(IRepository<User> userRepository, public UserService(IRepository<User> userRepository,
@ -44,6 +46,7 @@ namespace IRaCIS.Application.Services
IRepository<VerificationCode> verificationCodeRepository, IRepository<VerificationCode> verificationCodeRepository,
IRepository<Doctor> doctorRepository, IRepository<Doctor> doctorRepository,
IEasyCachingProvider cache, IEasyCachingProvider cache,
ISearcher searcher,
IReadingImageTaskService readingImageTaskService, IReadingImageTaskService readingImageTaskService,
IRepository<TrialUser> userTrialRepository, IRepository<TrialUser> userTrialRepository,
IOptionsMonitor<ServiceVerifyConfigOption> verifyConfig, IOptionsMonitor<ServiceVerifyConfigOption> verifyConfig,
@ -57,6 +60,7 @@ namespace IRaCIS.Application.Services
this._userPassWordLogRepository = userPassWordLogRepository; this._userPassWordLogRepository = userPassWordLogRepository;
_verifyConfig = verifyConfig; _verifyConfig = verifyConfig;
_cache = cache; _cache = cache;
this._searcher = searcher;
this._readingImageTaskService = readingImageTaskService; this._readingImageTaskService = readingImageTaskService;
_userRepository = userRepository; _userRepository = userRepository;
_mailVerificationService = mailVerificationService; _mailVerificationService = mailVerificationService;
@ -802,12 +806,14 @@ namespace IRaCIS.Application.Services
//登录成功 清除缓存 //登录成功 清除缓存
_cache.Set(cacheKey, 0, TimeSpan.FromMinutes(lockoutMinutes)); _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) if (loginUser.LastLoginIP != string.Empty)
{ {
// 与上一次IP不一致 // 与上一次IP不一致
if (loginUser.LastLoginIP != _userInfo.IP) if (loginUser.LastLoginIP != iPRegion)
{ {
loginUser.LoginState = 2; loginUser.LoginState = 2;
} }
@ -828,10 +834,10 @@ namespace IRaCIS.Application.Services
}); });
} }
await _userRepository.BatchUpdateNoTrackingAsync(x => x.Id == loginUser.Id, x => new User() await _userRepository.BatchUpdateNoTrackingAsync(x => x.Id == loginUser.Id, x => new User()
{ {
LastLoginIP = _userInfo.IP, LastLoginIP = iPRegion,
LastLoginTime = DateTime.Now LastLoginTime = DateTime.Now
}); });