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

Test_IRC_Net8
hang 2025-10-16 14:10:11 +08:00
parent 9a488610da
commit e6aec6b559
10 changed files with 41 additions and 13 deletions

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,

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": {

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": {

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
}, },

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": {

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": {

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": {

View File

@ -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;

View File

@ -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

View File

@ -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;