From e6aec6b559a13cc46deac60b5f39387d0085ff6b Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Thu, 16 Oct 2025 14:10:11 +0800 Subject: [PATCH] =?UTF-8?q?MFA=E7=8A=B6=E6=80=81=E6=8C=81=E4=B9=85?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRaCIS.Core.API/appsettings.Event_IRC.json | 4 +++- IRaCIS.Core.API/appsettings.Prod_IRC.json | 4 +++- IRaCIS.Core.API/appsettings.Test_IRC.json | 4 +++- IRaCIS.Core.API/appsettings.US_Prod_IRC.json | 4 +++- IRaCIS.Core.API/appsettings.US_Test_IRC.json | 4 +++- IRaCIS.Core.API/appsettings.US_Uat_IRC.json | 4 +++- IRaCIS.Core.API/appsettings.Uat_IRC.json | 4 +++- .../BusinessFilter/_Config/_AppSettings.cs | 8 +++++--- IRaCIS.Core.Application/Helper/CacheHelper.cs | 3 +++ .../Service/Management/UserService.cs | 15 ++++++++++++--- 10 files changed, 41 insertions(+), 13 deletions(-) diff --git a/IRaCIS.Core.API/appsettings.Event_IRC.json b/IRaCIS.Core.API/appsettings.Event_IRC.json index 6ec66b5b2..fa202a0b4 100644 --- a/IRaCIS.Core.API/appsettings.Event_IRC.json +++ b/IRaCIS.Core.API/appsettings.Event_IRC.json @@ -55,7 +55,9 @@ "ChangePassWordDays": 90, // 模板类型 1 Elevate 2 Extensive - "TemplateType": 2 + "TemplateType": 2, + //MFA免验证发送天数 + "UserMFAVerifyDays": 1 }, "SystemEmailSendConfig": { "Port": 465, diff --git a/IRaCIS.Core.API/appsettings.Prod_IRC.json b/IRaCIS.Core.API/appsettings.Prod_IRC.json index 9985c978b..c4b190731 100644 --- a/IRaCIS.Core.API/appsettings.Prod_IRC.json +++ b/IRaCIS.Core.API/appsettings.Prod_IRC.json @@ -53,7 +53,9 @@ "IsNeedChangePassWord": true, "ChangePassWordDays": 90, // 模板类型 1 Elevate 2 Extensive - "TemplateType": 2 + "TemplateType": 2, + //MFA免验证发送天数 + "UserMFAVerifyDays": 1 }, "SystemEmailSendConfig": { diff --git a/IRaCIS.Core.API/appsettings.Test_IRC.json b/IRaCIS.Core.API/appsettings.Test_IRC.json index a86722863..3bfe670ee 100644 --- a/IRaCIS.Core.API/appsettings.Test_IRC.json +++ b/IRaCIS.Core.API/appsettings.Test_IRC.json @@ -115,7 +115,9 @@ // 是否打开项目关联删除 "OpenTrialRelationDelete": true, // 转换PDF服务配置 - "ThirdPdfUrl": "http://106.14.89.110:30088/api/v1/convert/file/pdf" + "ThirdPdfUrl": "http://106.14.89.110:30088/api/v1/convert/file/pdf", + //MFA免验证发送天数 + "UserMFAVerifyDays": 1 }, // 邮件服务配置(用于系统通知、找回密码、错误报警等) "SystemEmailSendConfig": { diff --git a/IRaCIS.Core.API/appsettings.US_Prod_IRC.json b/IRaCIS.Core.API/appsettings.US_Prod_IRC.json index 286366cfc..30d98e886 100644 --- a/IRaCIS.Core.API/appsettings.US_Prod_IRC.json +++ b/IRaCIS.Core.API/appsettings.US_Prod_IRC.json @@ -57,7 +57,9 @@ // 模板类型 1 Elevate 2 Extensive "TemplateType": 1, - "OpenTrialRelationDelete": false + "OpenTrialRelationDelete": false, + //MFA免验证发送天数 + "UserMFAVerifyDays": 1 }, diff --git a/IRaCIS.Core.API/appsettings.US_Test_IRC.json b/IRaCIS.Core.API/appsettings.US_Test_IRC.json index df94467fb..743d350cb 100644 --- a/IRaCIS.Core.API/appsettings.US_Test_IRC.json +++ b/IRaCIS.Core.API/appsettings.US_Test_IRC.json @@ -66,7 +66,9 @@ "ChangePassWordDays": 90, // 模板类型 1 Elevate 2 Extensive "TemplateType": 1, - "OpenLoginMFA": true + "OpenLoginMFA": true, + //MFA免验证发送天数 + "UserMFAVerifyDays": 1 }, "SystemEmailSendConfig": { diff --git a/IRaCIS.Core.API/appsettings.US_Uat_IRC.json b/IRaCIS.Core.API/appsettings.US_Uat_IRC.json index 29856f89e..f995f33d0 100644 --- a/IRaCIS.Core.API/appsettings.US_Uat_IRC.json +++ b/IRaCIS.Core.API/appsettings.US_Uat_IRC.json @@ -65,7 +65,9 @@ "IsNeedChangePassWord": true, "ChangePassWordDays": 90, // 模板类型 1 Elevate 2 Extensive - "TemplateType": 1 + "TemplateType": 1, + //MFA免验证发送天数 + "UserMFAVerifyDays": 1 }, "SystemEmailSendConfig": { diff --git a/IRaCIS.Core.API/appsettings.Uat_IRC.json b/IRaCIS.Core.API/appsettings.Uat_IRC.json index 05eaba3c2..5906b8018 100644 --- a/IRaCIS.Core.API/appsettings.Uat_IRC.json +++ b/IRaCIS.Core.API/appsettings.Uat_IRC.json @@ -72,7 +72,9 @@ "IsNeedChangePassWord": true, "ChangePassWordDays": 90, // 模板类型 1 Elevate 2 Extensive - "TemplateType": 2 + "TemplateType": 2, + //MFA免验证发送天数 + "UserMFAVerifyDays": 1 }, "SystemEmailSendConfig": { diff --git a/IRaCIS.Core.Application/BusinessFilter/_Config/_AppSettings.cs b/IRaCIS.Core.Application/BusinessFilter/_Config/_AppSettings.cs index f4bd22935..811ca1563 100644 --- a/IRaCIS.Core.Application/BusinessFilter/_Config/_AppSettings.cs +++ b/IRaCIS.Core.Application/BusinessFilter/_Config/_AppSettings.cs @@ -38,6 +38,8 @@ public class ServiceVerifyConfigOption public string ThirdPdfUrl { get; set; } + public int UserMFAVerifyDays { get; set; } = 1; + } public class SystemEmailSendConfig @@ -53,7 +55,7 @@ public class SystemEmailSendConfig public string SiteUrl { get; set; } = string.Empty; - public string SystemShortName { get; set; } = string.Empty; + public string SystemShortName { get; set; } = string.Empty; public string OrganizationName { get; set; } = string.Empty; public string OrganizationNameCN { get; set; } = string.Empty; @@ -72,12 +74,12 @@ public class SystemEmailSendConfig public string EmailRegexStr { get; set; } - public List ErrorNoticeEmailList { get; set; } =new List(); + public List ErrorNoticeEmailList { get; set; } = new List(); } public class SystemEmailSendConfigView { - public string SystemShortName { get; set; } = string.Empty; + public string SystemShortName { get; set; } = string.Empty; public string CompanyName { get; set; } = string.Empty; public string CompanyNameCN { get; set; } = string.Empty; diff --git a/IRaCIS.Core.Application/Helper/CacheHelper.cs b/IRaCIS.Core.Application/Helper/CacheHelper.cs index fa33c859e..4d340bb5e 100644 --- a/IRaCIS.Core.Application/Helper/CacheHelper.cs +++ b/IRaCIS.Core.Application/Helper/CacheHelper.cs @@ -61,6 +61,9 @@ public static class CacheKeys /// public static string StartRestTime(Guid userId) => $"{userId}StartRestTime"; + + public static string UserMFAVerifyPass(Guid userId) => $"UserMFAVerifyPass:{userId}"; + } public static class CacheHelper diff --git a/IRaCIS.Core.Application/Service/Management/UserService.cs b/IRaCIS.Core.Application/Service/Management/UserService.cs index a05c095da..cda31390b 100644 --- a/IRaCIS.Core.Application/Service/Management/UserService.cs +++ b/IRaCIS.Core.Application/Service/Management/UserService.cs @@ -40,7 +40,7 @@ namespace IRaCIS.Core.Application.Service IRepository _doctorRepository, ISearcher _searcher, IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer, IFusionCache _fusionCache) : BaseService, IUserService { - + private ServiceVerifyConfigOption _serviceVerifyConfigConfig = _verifyConfig.CurrentValue; private SystemEmailSendConfig _systemEmailConfig = systemEmailConfig.CurrentValue; private async Task VerifyUserNameAsync(Guid? identityUserId, string userName) @@ -857,6 +857,8 @@ namespace IRaCIS.Core.Application.Service } } + await _fusionCache.SetAsync(CacheKeys.UserMFAVerifyPass(identityUserId), true, TimeSpan.FromDays(_serviceVerifyConfigConfig.UserMFAVerifyDays)); + return ResponseOutput.Ok(); } @@ -1120,9 +1122,16 @@ namespace IRaCIS.Core.Application.Service if (_verifyConfig.CurrentValue.OpenLoginMFA) { - //MFA 发送邮件 + if ((await _fusionCache.GetOrDefaultAsync(CacheKeys.UserMFAVerifyPass(identityUserId), false)) == true) + { + userLoginReturnModel.IsMFA = false; + } + else + { + //MFA 发送邮件 - userLoginReturnModel.IsMFA = true; + userLoginReturnModel.IsMFA = true; + } var email = userLoginReturnModel.BasicInfo.EMail;