工作单元 +发送邮件提示修改
parent
3bbba03113
commit
5805393d76
|
@ -76,7 +76,7 @@ namespace IRaCIS.Core.API
|
||||||
//options.Filters.Add<LogActionFilter>();
|
//options.Filters.Add<LogActionFilter>();
|
||||||
options.Filters.Add<ModelActionFilter>();
|
options.Filters.Add<ModelActionFilter>();
|
||||||
options.Filters.Add<ProjectExceptionFilter>();
|
options.Filters.Add<ProjectExceptionFilter>();
|
||||||
//options.Filters.Add<UnitOfWorkFilter>();
|
options.Filters.Add<UnitOfWorkFilter>();
|
||||||
|
|
||||||
if (_configuration.GetSection("BasicSystemConfig").GetValue<bool>("OpenLoginLimit"))
|
if (_configuration.GetSection("BasicSystemConfig").GetValue<bool>("OpenLoginLimit"))
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,6 +9,8 @@ public static class SendEmailHelper
|
||||||
{
|
{
|
||||||
|
|
||||||
public static async Task SendEmailAsync(MimeMessage messageToSend, EventHandler<MessageSentEventArgs>? messageSentSuccess = null)
|
public static async Task SendEmailAsync(MimeMessage messageToSend, EventHandler<MessageSentEventArgs>? messageSentSuccess = null)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
using (var smtp = new MailKit.Net.Smtp.SmtpClient())
|
using (var smtp = new MailKit.Net.Smtp.SmtpClient())
|
||||||
{
|
{
|
||||||
|
@ -30,6 +32,14 @@ public static class SendEmailHelper
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
|
||||||
|
throw new Exception("邮件发送失败,您进行的操作未能成功,请检查邮箱或联系维护人员") ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public static async Task SendEmailAsync(SMTPEmailConfig sMTPEmailConfig, EventHandler<MessageSentEventArgs>? messageSentSuccess = null)
|
public static async Task SendEmailAsync(SMTPEmailConfig sMTPEmailConfig, EventHandler<MessageSentEventArgs>? messageSentSuccess = null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -124,6 +124,7 @@ namespace IRaCIS.Application.Services
|
||||||
|
|
||||||
|
|
||||||
[HttpPut("{newEmail}/{verificationCode}")]
|
[HttpPut("{newEmail}/{verificationCode}")]
|
||||||
|
[UnitOfWork]
|
||||||
public async Task<IResponseOutput> SetNewEmail(string newEmail, string verificationCode)
|
public async Task<IResponseOutput> SetNewEmail(string newEmail, string verificationCode)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -244,7 +245,7 @@ namespace IRaCIS.Application.Services
|
||||||
/// <param name="userId"></param>
|
/// <param name="userId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet("{userId:guid}")]
|
[HttpGet("{userId:guid}")]
|
||||||
|
[UnitOfWork]
|
||||||
public async Task<IResponseOutput> ResetPassword(Guid userId)
|
public async Task<IResponseOutput> ResetPassword(Guid userId)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -256,7 +257,15 @@ namespace IRaCIS.Application.Services
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
await _mailVerificationService.AdminResetPwdSendEmailAsync(userId, pwd);
|
await _mailVerificationService.AdminResetPwdSendEmailAsync(userId, pwd);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
throw new BusinessValidationFailedException("请检查邮箱地址或者联系维护人员, 邮件发送失败, 未能创建账户成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
await _userRepository.UpdatePartialNowNoQueryAsync(userId, u => new User()
|
await _userRepository.UpdatePartialNowNoQueryAsync(userId, u => new User()
|
||||||
{
|
{
|
||||||
|
@ -494,8 +503,12 @@ namespace IRaCIS.Application.Services
|
||||||
|
|
||||||
var success = await _userRepository.SaveChangesAsync();
|
var success = await _userRepository.SaveChangesAsync();
|
||||||
|
|
||||||
|
|
||||||
await _mailVerificationService.AddUserSendEmailAsync(saveItem.Id, userAddModel.BaseUrl, userAddModel.RouteUrl);
|
await _mailVerificationService.AddUserSendEmailAsync(saveItem.Id, userAddModel.BaseUrl, userAddModel.RouteUrl);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return ResponseOutput.Result(success, new UserAddedReturnDTO { Id = saveItem.Id, UserCode = saveItem.UserCode });
|
return ResponseOutput.Result(success, new UserAddedReturnDTO { Id = saveItem.Id, UserCode = saveItem.UserCode });
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -199,6 +199,7 @@ namespace IRaCIS.Core.Application.Service
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Authorize(Policy = IRaCISPolicy.PM_APM)]
|
[Authorize(Policy = IRaCISPolicy.PM_APM)]
|
||||||
[TypeFilter(typeof(TrialResourceFilter))]
|
[TypeFilter(typeof(TrialResourceFilter))]
|
||||||
|
[UnitOfWork]
|
||||||
public async Task<IResponseOutput> SendExternalUserJoinEmail(TrialExternalUserSendEmail sendEmail)
|
public async Task<IResponseOutput> SendExternalUserJoinEmail(TrialExternalUserSendEmail sendEmail)
|
||||||
{
|
{
|
||||||
var trialId = sendEmail.TrialId;
|
var trialId = sendEmail.TrialId;
|
||||||
|
@ -207,6 +208,7 @@ namespace IRaCIS.Core.Application.Service
|
||||||
{
|
{
|
||||||
var userId = userInfo.SystemUserId;
|
var userId = userInfo.SystemUserId;
|
||||||
|
|
||||||
|
|
||||||
await _mailVerificationService.ExternalUserJoinEmail(trialId, userId, sendEmail.BaseUrl, sendEmail.RouteUrl);
|
await _mailVerificationService.ExternalUserJoinEmail(trialId, userId, sendEmail.BaseUrl, sendEmail.RouteUrl);
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue