diff --git a/IRaCIS.Core.Application/Service/Common/MailService.cs b/IRaCIS.Core.Application/Service/Common/MailService.cs index 3acfa9ebd..588761284 100644 --- a/IRaCIS.Core.Application/Service/Common/MailService.cs +++ b/IRaCIS.Core.Application/Service/Common/MailService.cs @@ -21,7 +21,7 @@ namespace IRaCIS.Application.Services 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); @@ -94,7 +94,7 @@ namespace IRaCIS.Application.Services } //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(); //发件地址 @@ -103,7 +103,7 @@ namespace IRaCIS.Application.Services messageToSend.To.Add(new MailboxAddress(userName, emailAddress)); //主题 //---[来自{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(); @@ -123,7 +123,7 @@ namespace IRaCIS.Application.Services builder.HtmlBody = string.Format(ReplaceCompanyName(templateInfo), userName, - _localizer["Mail_MFAEmail"], + _localizer[mfaType == UserMFAType.Login ? "Mail_EmailMFALoginEmail": "Mail_EmailMFAUnlockEmail"], verificationCode ); } diff --git a/IRaCIS.Core.Application/Service/Management/Interface/IUserService.cs b/IRaCIS.Core.Application/Service/Management/Interface/IUserService.cs index 873fced43..80a80bc94 100644 --- a/IRaCIS.Core.Application/Service/Management/Interface/IUserService.cs +++ b/IRaCIS.Core.Application/Service/Management/Interface/IUserService.cs @@ -12,7 +12,7 @@ namespace IRaCIS.Application.Services Task> Login(string userName, string password); Task VerifyMFACodeAsync(Guid userId, string Code); - Task SendMFAEmail(Guid userId); + Task SendMFAEmail(Guid userId, UserMFAType mfaType); Task GetUserBasicInfo(Guid userId,string pwd); Task ModifyPassword(EditPasswordCommand editPwModel); Task ResetPassword(Guid userId); diff --git a/IRaCIS.Core.Application/Service/Management/UserService.cs b/IRaCIS.Core.Application/Service/Management/UserService.cs index ab4a221c2..57ff8e49d 100644 --- a/IRaCIS.Core.Application/Service/Management/UserService.cs +++ b/IRaCIS.Core.Application/Service/Management/UserService.cs @@ -653,15 +653,16 @@ namespace IRaCIS.Application.Services /// 发送MFA 验证邮件 /// /// + /// /// [AllowAnonymous] - public async Task SendMFAEmail(Guid userId) + public async Task SendMFAEmail(Guid userId, UserMFAType mfaType = UserMFAType.Login) { var userInfo = await _userRepository.Where(u => u.Id == userId).Select(t => new { t.FullName, t.EMail }).FirstOrDefaultAsync(); 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(); } diff --git a/IRaCIS.Core.Domain.Share/User/UserType.cs b/IRaCIS.Core.Domain.Share/User/UserType.cs index fb583c742..b38f45d76 100644 --- a/IRaCIS.Core.Domain.Share/User/UserType.cs +++ b/IRaCIS.Core.Domain.Share/User/UserType.cs @@ -90,6 +90,13 @@ EnrollOrPD_EMailCopy=5, } + public enum UserMFAType + { + Login=0, + + Unlock=1, + } + } \ No newline at end of file