MFA状态持久管理修改
continuous-integration/drone/push Build is passing

This commit is contained in:
2025-10-16 14:10:11 +08:00
parent 9a488610da
commit e6aec6b559
10 changed files with 41 additions and 13 deletions
+3 -1
View File
@@ -55,7 +55,9 @@
"ChangePassWordDays": 90, "ChangePassWordDays": 90,
// 模板类型 1 Elevate 2 Extensive // 模板类型 1 Elevate 2 Extensive
"TemplateType": 2 "TemplateType": 2,
//MFA免验证发送天数
"UserMFAVerifyDays": 1
}, },
"SystemEmailSendConfig": { "SystemEmailSendConfig": {
"Port": 465, "Port": 465,
+3 -1
View File
@@ -53,7 +53,9 @@
"IsNeedChangePassWord": true, "IsNeedChangePassWord": true,
"ChangePassWordDays": 90, "ChangePassWordDays": 90,
// 模板类型 1 Elevate 2 Extensive // 模板类型 1 Elevate 2 Extensive
"TemplateType": 2 "TemplateType": 2,
//MFA免验证发送天数
"UserMFAVerifyDays": 1
}, },
"SystemEmailSendConfig": { "SystemEmailSendConfig": {
+3 -1
View File
@@ -115,7 +115,9 @@
// 是否打开项目关联删除 // 是否打开项目关联删除
"OpenTrialRelationDelete": true, "OpenTrialRelationDelete": true,
// 转换PDF服务配置 // 转换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": { "SystemEmailSendConfig": {
+3 -1
View File
@@ -57,7 +57,9 @@
// 模板类型 1 Elevate 2 Extensive // 模板类型 1 Elevate 2 Extensive
"TemplateType": 1, "TemplateType": 1,
"OpenTrialRelationDelete": false "OpenTrialRelationDelete": false,
//MFA免验证发送天数
"UserMFAVerifyDays": 1
}, },
+3 -1
View File
@@ -66,7 +66,9 @@
"ChangePassWordDays": 90, "ChangePassWordDays": 90,
// 模板类型 1 Elevate 2 Extensive // 模板类型 1 Elevate 2 Extensive
"TemplateType": 1, "TemplateType": 1,
"OpenLoginMFA": true "OpenLoginMFA": true,
//MFA免验证发送天数
"UserMFAVerifyDays": 1
}, },
"SystemEmailSendConfig": { "SystemEmailSendConfig": {
+3 -1
View File
@@ -65,7 +65,9 @@
"IsNeedChangePassWord": true, "IsNeedChangePassWord": true,
"ChangePassWordDays": 90, "ChangePassWordDays": 90,
// 模板类型 1 Elevate 2 Extensive // 模板类型 1 Elevate 2 Extensive
"TemplateType": 1 "TemplateType": 1,
//MFA免验证发送天数
"UserMFAVerifyDays": 1
}, },
"SystemEmailSendConfig": { "SystemEmailSendConfig": {
+3 -1
View File
@@ -72,7 +72,9 @@
"IsNeedChangePassWord": true, "IsNeedChangePassWord": true,
"ChangePassWordDays": 90, "ChangePassWordDays": 90,
// 模板类型 1 Elevate 2 Extensive // 模板类型 1 Elevate 2 Extensive
"TemplateType": 2 "TemplateType": 2,
//MFA免验证发送天数
"UserMFAVerifyDays": 1
}, },
"SystemEmailSendConfig": { "SystemEmailSendConfig": {
@@ -38,6 +38,8 @@ public class ServiceVerifyConfigOption
public string ThirdPdfUrl { get; set; } public string ThirdPdfUrl { get; set; }
public int UserMFAVerifyDays { get; set; } = 1;
} }
public class SystemEmailSendConfig public class SystemEmailSendConfig
@@ -53,7 +55,7 @@ public class SystemEmailSendConfig
public string SiteUrl { get; set; } = string.Empty; 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 OrganizationName { get; set; } = string.Empty;
public string OrganizationNameCN { get; set; } = string.Empty; public string OrganizationNameCN { get; set; } = string.Empty;
@@ -72,12 +74,12 @@ public class SystemEmailSendConfig
public string EmailRegexStr { get; set; } public string EmailRegexStr { get; set; }
public List<string> ErrorNoticeEmailList { get; set; } =new List<string>(); public List<string> ErrorNoticeEmailList { get; set; } = new List<string>();
} }
public class SystemEmailSendConfigView 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 CompanyName { get; set; } = string.Empty;
public string CompanyNameCN { get; set; } = string.Empty; public string CompanyNameCN { get; set; } = string.Empty;
@@ -61,6 +61,9 @@ public static class CacheKeys
/// <returns></returns> /// <returns></returns>
public static string StartRestTime(Guid userId) => $"{userId}StartRestTime"; public static string StartRestTime(Guid userId) => $"{userId}StartRestTime";
public static string UserMFAVerifyPass(Guid userId) => $"UserMFAVerifyPass:{userId}";
} }
public static class CacheHelper public static class CacheHelper
@@ -40,7 +40,7 @@ namespace IRaCIS.Core.Application.Service
IRepository<Doctor> _doctorRepository, IRepository<Doctor> _doctorRepository,
ISearcher _searcher, IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer, IFusionCache _fusionCache) : BaseService, IUserService ISearcher _searcher, IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer, IFusionCache _fusionCache) : BaseService, IUserService
{ {
private ServiceVerifyConfigOption _serviceVerifyConfigConfig = _verifyConfig.CurrentValue;
private SystemEmailSendConfig _systemEmailConfig = systemEmailConfig.CurrentValue; private SystemEmailSendConfig _systemEmailConfig = systemEmailConfig.CurrentValue;
private async Task VerifyUserNameAsync(Guid? identityUserId, string userName) 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(); return ResponseOutput.Ok();
} }
@@ -1120,9 +1122,16 @@ namespace IRaCIS.Core.Application.Service
if (_verifyConfig.CurrentValue.OpenLoginMFA) 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; var email = userLoginReturnModel.BasicInfo.EMail;