修改MFA 接口
continuous-integration/drone/push Build is failing Details

IRC_NewDev
hang 2024-06-14 10:38:58 +08:00
parent ae913d8213
commit 6207fb5006
4 changed files with 15 additions and 7 deletions

View File

@ -21,7 +21,7 @@ namespace IRaCIS.Application.Services
Task SiteSurveyRejectEmail(MimeMessage messageToSend); Task SiteSurveyRejectEmail(MimeMessage messageToSend);
Task SenMFAVerifyEmail(Guid userId, string userName, string emailAddress, int verificationCode); Task SenMFAVerifyEmail(Guid userId, string userName, string emailAddress, int verificationCode, UserMFAType mfaType = UserMFAType.Login);
Task SendMailEditEmail(Guid userId, string userName, string emailAddress, int verificationCode); Task SendMailEditEmail(Guid userId, string userName, string emailAddress, int verificationCode);
@ -94,7 +94,7 @@ namespace IRaCIS.Application.Services
} }
//MFA //MFA
public async Task SenMFAVerifyEmail(Guid userId, string userName, string emailAddress, int verificationCode) public async Task SenMFAVerifyEmail(Guid userId, string userName, string emailAddress, int verificationCode, UserMFAType mfaType = UserMFAType.Login)
{ {
var messageToSend = new MimeMessage(); var messageToSend = new MimeMessage();
//发件地址 //发件地址
@ -103,7 +103,7 @@ namespace IRaCIS.Application.Services
messageToSend.To.Add(new MailboxAddress(userName, emailAddress)); messageToSend.To.Add(new MailboxAddress(userName, emailAddress));
//主题 //主题
//---[来自{0}] 关于MFA邮箱验证的提醒 //---[来自{0}] 关于MFA邮箱验证的提醒
messageToSend.Subject = _localizer["Mail_EmailMFATopic", _userInfo.IsEn_Us ? _systemEmailConfig.CompanyShortName : _systemEmailConfig.CompanyShortNameCN]; messageToSend.Subject = _localizer[mfaType == UserMFAType.Login? "Mail_EmailMFALoginTopic":"Mail_EmailMFAUnlockTopic", _userInfo.IsEn_Us ? _systemEmailConfig.CompanyShortName : _systemEmailConfig.CompanyShortNameCN];
var builder = new BodyBuilder(); var builder = new BodyBuilder();
@ -123,7 +123,7 @@ namespace IRaCIS.Application.Services
builder.HtmlBody = string.Format(ReplaceCompanyName(templateInfo), builder.HtmlBody = string.Format(ReplaceCompanyName(templateInfo),
userName, userName,
_localizer["Mail_MFAEmail"], _localizer[mfaType == UserMFAType.Login ? "Mail_EmailMFALoginEmail": "Mail_EmailMFAUnlockEmail"],
verificationCode verificationCode
); );
} }

View File

@ -12,7 +12,7 @@ namespace IRaCIS.Application.Services
Task<IResponseOutput<LoginReturnDTO>> Login(string userName, string password); Task<IResponseOutput<LoginReturnDTO>> Login(string userName, string password);
Task<IResponseOutput> VerifyMFACodeAsync(Guid userId, string Code); Task<IResponseOutput> VerifyMFACodeAsync(Guid userId, string Code);
Task<IResponseOutput> SendMFAEmail(Guid userId); Task<IResponseOutput> SendMFAEmail(Guid userId, UserMFAType mfaType);
Task<UserBasicInfo> GetUserBasicInfo(Guid userId,string pwd); Task<UserBasicInfo> GetUserBasicInfo(Guid userId,string pwd);
Task<IResponseOutput> ModifyPassword(EditPasswordCommand editPwModel); Task<IResponseOutput> ModifyPassword(EditPasswordCommand editPwModel);
Task<IResponseOutput> ResetPassword(Guid userId); Task<IResponseOutput> ResetPassword(Guid userId);

View File

@ -653,15 +653,16 @@ namespace IRaCIS.Application.Services
/// 发送MFA 验证邮件 /// 发送MFA 验证邮件
/// </summary> /// </summary>
/// <param name="userId"></param> /// <param name="userId"></param>
/// <param name="mfaType"></param>
/// <returns></returns> /// <returns></returns>
[AllowAnonymous] [AllowAnonymous]
public async Task<IResponseOutput> SendMFAEmail(Guid userId) public async Task<IResponseOutput> SendMFAEmail(Guid userId, UserMFAType mfaType = UserMFAType.Login)
{ {
var userInfo = await _userRepository.Where(u => u.Id == userId).Select(t => new { t.FullName, t.EMail }).FirstOrDefaultAsync(); var userInfo = await _userRepository.Where(u => u.Id == userId).Select(t => new { t.FullName, t.EMail }).FirstOrDefaultAsync();
int verificationCode = new Random().Next(100000, 1000000); int verificationCode = new Random().Next(100000, 1000000);
await _mailVerificationService.SenMFAVerifyEmail(userId, userInfo.FullName, userInfo.EMail, verificationCode); await _mailVerificationService.SenMFAVerifyEmail(userId, userInfo.FullName, userInfo.EMail, verificationCode, mfaType);
return ResponseOutput.Ok(); return ResponseOutput.Ok();
} }

View File

@ -90,6 +90,13 @@
EnrollOrPD_EMailCopy=5, EnrollOrPD_EMailCopy=5,
} }
public enum UserMFAType
{
Login=0,
Unlock=1,
}
} }