diff --git a/IRaCIS.Core.API/appsettings.Test_IRC.json b/IRaCIS.Core.API/appsettings.Test_IRC.json index fa496f94e..0f43fe7f1 100644 --- a/IRaCIS.Core.API/appsettings.Test_IRC.json +++ b/IRaCIS.Core.API/appsettings.Test_IRC.json @@ -117,7 +117,7 @@ // 转换PDF服务配置 "ThirdPdfUrl": "http://106.14.89.110:30088/api/v1/convert/file/pdf", //MFA免验证发送天数 - "UserMFAVerifyDays": 1 + "UserMFAVerifyMinutes": 1440 }, // 邮件服务配置(用于系统通知、找回密码、错误报警等) "SystemEmailSendConfig": { diff --git a/IRaCIS.Core.Application/BusinessFilter/_Config/_AppSettings.cs b/IRaCIS.Core.Application/BusinessFilter/_Config/_AppSettings.cs index aa433b847..cb1ff82a8 100644 --- a/IRaCIS.Core.Application/BusinessFilter/_Config/_AppSettings.cs +++ b/IRaCIS.Core.Application/BusinessFilter/_Config/_AppSettings.cs @@ -38,7 +38,7 @@ public class ServiceVerifyConfigOption public string ThirdPdfUrl { get; set; } - public int UserMFAVerifyDays { get; set; } = 1; + public int UserMFAVerifyMinutes { get; set; } = 1440; } diff --git a/IRaCIS.Core.Application/Helper/CacheHelper.cs b/IRaCIS.Core.Application/Helper/CacheHelper.cs index 4d340bb5e..850d7be88 100644 --- a/IRaCIS.Core.Application/Helper/CacheHelper.cs +++ b/IRaCIS.Core.Application/Helper/CacheHelper.cs @@ -61,8 +61,8 @@ public static class CacheKeys /// public static string StartRestTime(Guid userId) => $"{userId}StartRestTime"; - - public static string UserMFAVerifyPass(Guid userId) => $"UserMFAVerifyPass:{userId}"; + //每个用户 每个浏览器独立时间 + public static string UserMFAVerifyPass(Guid userId,string browserFingerprint) => $"UserMFAVerifyPass:{userId}:{browserFingerprint}"; } diff --git a/IRaCIS.Core.Application/Service/Management/UserService.cs b/IRaCIS.Core.Application/Service/Management/UserService.cs index 78e34ca93..77b1c03ab 100644 --- a/IRaCIS.Core.Application/Service/Management/UserService.cs +++ b/IRaCIS.Core.Application/Service/Management/UserService.cs @@ -861,7 +861,7 @@ namespace IRaCIS.Core.Application.Service if (isRemember) { - await _fusionCache.SetAsync(CacheKeys.UserMFAVerifyPass(identityUserId), _userInfo.BrowserFingerprint, TimeSpan.FromDays(_serviceVerifyConfigConfig.UserMFAVerifyDays)); + await _fusionCache.SetAsync(CacheKeys.UserMFAVerifyPass(identityUserId, _userInfo.BrowserFingerprint), _userInfo.BrowserFingerprint, TimeSpan.FromMinutes(_serviceVerifyConfigConfig.UserMFAVerifyMinutes)); } @@ -1107,9 +1107,9 @@ namespace IRaCIS.Core.Application.Service var userAgreementList = await _userAgreementRepository.Where(t => t.IsCurrentVersion).OrderByDescending(t => t.CreateTime).ToListAsync(); - var userAgreement= userAgreementList.FirstOrDefault(t => t.UserAgreementTypeEnum == UserAgreementType.UserAgreement); + var userAgreement = userAgreementList.FirstOrDefault(t => t.UserAgreementTypeEnum == UserAgreementType.UserAgreement); - if (userAgreement!=null&& loginUser.UserAgreementId!= userAgreement.Id) + if (userAgreement != null && loginUser.UserAgreementId != userAgreement.Id) { await _identityUserRepository.BatchUpdateNoTrackingAsync(x => x.Id == loginUser.IdentityUserId, x => new IdentityUser() { @@ -1119,13 +1119,13 @@ namespace IRaCIS.Core.Application.Service var obj = new { UserAgreementTypeEnum = UserAgreementType.UserAgreement, - FileVersion=userAgreement.FileVersion, - UserAgreementId=userAgreement.Id, - IsEn_Us= _userInfo.IsEn_Us, + FileVersion = userAgreement.FileVersion, + UserAgreementId = userAgreement.Id, + IsEn_Us = _userInfo.IsEn_Us, }; - - await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, ActionIdentityUserId = loginUser.IdentityUserId, ActionUserName = loginUser.UserName, OptType = UserOptType.AcceptUserAgreement, JsonObj= obj.ToJsonStr() }, true); + + await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, ActionIdentityUserId = loginUser.IdentityUserId, ActionUserName = loginUser.UserName, OptType = UserOptType.AcceptUserAgreement, JsonObj = obj.ToJsonStr() }, true); } @@ -1176,7 +1176,7 @@ namespace IRaCIS.Core.Application.Service if (_verifyConfig.CurrentValue.OpenLoginMFA) { - if ((await _fusionCache.GetOrDefaultAsync(CacheKeys.UserMFAVerifyPass(identityUserId), "")) == _userInfo.BrowserFingerprint) + if ((await _fusionCache.GetOrDefaultAsync(CacheKeys.UserMFAVerifyPass(identityUserId, _userInfo.BrowserFingerprint), "")) == _userInfo.BrowserFingerprint) { userLoginReturnModel.IsMFA = false; } @@ -1196,9 +1196,10 @@ namespace IRaCIS.Core.Application.Service //修改密码 || 90天修改密码再mfa 之前 if (userLoginReturnModel.BasicInfo.IsFirstAdd || userLoginReturnModel.BasicInfo.NeedChangePassWord) { + //移动到上面去了 //userLoginReturnModel.JWTStr = _tokenService.GetToken(userLoginReturnModel.BasicInfo); } - else + else if (userLoginReturnModel.IsMFA == true) { //正常登录才发送邮件 await SendMFAEmail(new SendMfaCommand() { IdentityUserId = identityUserId, MFAType = UserMFAType.Login });