上传bug
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using IRaCIS.Core.Infra.EFCore;
|
||||
using IRaCIS.Core.Domain.Models;
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
using MailKit.Security;
|
||||
using MimeKit;
|
||||
|
||||
@@ -9,11 +10,11 @@ namespace IRaCIS.Application.Services
|
||||
{
|
||||
Task SendMail(Guid userId, string userName, string emailAddress, int verificationCode);
|
||||
|
||||
Task AnolymousSendEmail(string emailAddress, int verificationCode);
|
||||
Task AnolymousSendEmail(string researchProgramNo ,string emailAddress, int verificationCode);
|
||||
|
||||
Task SendMailEditEmail(Guid userId, string userName, string emailAddress, int verificationCode);
|
||||
|
||||
Task AnolymousSendEmailForResetAccount(string emailAddress, int verificationCode);
|
||||
Task AnolymousSendEmailForResetAccount( string emailAddress, int verificationCode);
|
||||
}
|
||||
|
||||
public class MailVerificationService : IMailVerificationService
|
||||
@@ -41,13 +42,15 @@ namespace IRaCIS.Application.Services
|
||||
//收件地址
|
||||
messageToSend.To.Add(new MailboxAddress(userName, emailAddress));
|
||||
//主题
|
||||
messageToSend.Subject = "Reset email (Verification Code)";
|
||||
messageToSend.Subject = "重置邮箱";
|
||||
|
||||
messageToSend.Body = new TextPart("plain")
|
||||
{
|
||||
Text = $@"Hey {userName},you are modify your email . The verification code is: {verificationCode}, which is valid within 3 minutes. If it is not your own operation, please ignore it!
|
||||
|
||||
-- GRR"
|
||||
Text = $@" {userName},您好:
|
||||
感谢您使用展影云平台。
|
||||
您正在进行邮箱重置操作,验证码是: {verificationCode},请在3分钟内输入该验证码,进行后续操作。如非本人操作,请忽略该邮件
|
||||
此邮件属系统自动发出,无需回复。
|
||||
上海展影医疗科技有限公司"
|
||||
};
|
||||
using (var smtp = new MailKit.Net.Smtp.SmtpClient())
|
||||
{
|
||||
@@ -80,59 +83,7 @@ namespace IRaCIS.Application.Services
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task SendMail(Guid userId, string userName, string emailAddress, int verificationCode)
|
||||
{
|
||||
|
||||
|
||||
var messageToSend = new MimeMessage();
|
||||
//发件地址
|
||||
messageToSend.From.Add(new MailboxAddress("GRR", "iracis_grr@163.com"));
|
||||
//收件地址
|
||||
messageToSend.To.Add(new MailboxAddress(userName, emailAddress));
|
||||
//主题
|
||||
messageToSend.Subject = "Reset PassWord (Verification Code)";
|
||||
|
||||
messageToSend.Body = new TextPart("plain")
|
||||
{
|
||||
Text = $@"Hey {userName},you are resetting your password via email. The verification code is: {verificationCode}, which is valid within 3 minutes. If it is not your own operation, please ignore it!
|
||||
|
||||
-- GRR"
|
||||
};
|
||||
using (var smtp = new MailKit.Net.Smtp.SmtpClient())
|
||||
{
|
||||
smtp.MessageSent += (sender, args) =>
|
||||
{
|
||||
// args.Response
|
||||
var code = verificationCode.ToString();
|
||||
_ = _verificationCodeRepository.AddAsync(new VerificationCode()
|
||||
{
|
||||
CodeType = 0,
|
||||
HasSend = true,
|
||||
Code = code,
|
||||
UserId = userId,
|
||||
ExpirationTime = DateTime.Now.AddMinutes(3)
|
||||
}).Result;
|
||||
_ = _verificationCodeRepository.SaveChangesAsync().Result;
|
||||
|
||||
};
|
||||
|
||||
smtp.ServerCertificateValidationCallback = (s, c, h, e) => true;
|
||||
|
||||
await smtp.ConnectAsync("smtp.163.com", 25, SecureSocketOptions.StartTls);
|
||||
|
||||
await smtp.AuthenticateAsync("iracis_grr@163.com", "XLWVQKZAEKLDWOAH");
|
||||
|
||||
await smtp.SendAsync(messageToSend);
|
||||
|
||||
await smtp.DisconnectAsync(true);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public async Task AnolymousSendEmailForResetAccount(string emailAddress, int verificationCode)
|
||||
public async Task AnolymousSendEmailForResetAccount( string emailAddress, int verificationCode)
|
||||
{
|
||||
var messageToSend = new MimeMessage();
|
||||
//发件地址
|
||||
@@ -140,13 +91,15 @@ namespace IRaCIS.Application.Services
|
||||
//收件地址
|
||||
messageToSend.To.Add(new MailboxAddress(String.Empty, emailAddress));
|
||||
//主题
|
||||
messageToSend.Subject = "Reset Password (Verification Code)";
|
||||
messageToSend.Subject = "重置密码";
|
||||
|
||||
messageToSend.Body = new TextPart("plain")
|
||||
{
|
||||
Text = $@"Hey ,you are reset passwoed. The verification code is: {verificationCode}, If it is not your own operation, please ignore it!
|
||||
|
||||
-- GRR"
|
||||
Text = $@" 您好:
|
||||
感谢您使用展影云平台。
|
||||
您正在进行邮箱重置密码操作,验证码是: {verificationCode},请在3分钟内输入该验证码,进行后续操作。如非本人操作,请忽略该邮件
|
||||
此邮件属系统自动发出,无需回复。
|
||||
上海展影医疗科技有限公司"
|
||||
};
|
||||
using (var smtp = new MailKit.Net.Smtp.SmtpClient())
|
||||
{
|
||||
@@ -180,24 +133,24 @@ namespace IRaCIS.Application.Services
|
||||
}
|
||||
|
||||
|
||||
public async Task AnolymousSendEmail(string emailAddress, int verificationCode)
|
||||
public async Task AnolymousSendEmail(string researchProgramNo,string emailAddress, int verificationCode)
|
||||
{
|
||||
|
||||
|
||||
|
||||
var messageToSend = new MimeMessage();
|
||||
//发件地址
|
||||
messageToSend.From.Add(new MailboxAddress("GRR", "iracis_grr@163.com"));
|
||||
//收件地址
|
||||
messageToSend.To.Add(new MailboxAddress(String.Empty, emailAddress));
|
||||
//主题
|
||||
messageToSend.Subject = "GRR Site survey (Verification Code)";
|
||||
messageToSend.Subject = $"[{researchProgramNo}]中心调研";
|
||||
|
||||
messageToSend.Body = new TextPart("plain")
|
||||
{
|
||||
Text = $@"Hey ,you are login for site survey via email. The verification code is: {verificationCode}, which is valid within 3 minutes. If it is not your own operation, please ignore it!
|
||||
|
||||
-- GRR"
|
||||
Text = $@" 感谢您使用展影云平台。
|
||||
您正在参与展影医疗IRC项目中心调研工作,验证码是:: {verificationCode},请在3分钟内输入该验证码,进行后续操作。如非本人操作,请忽略该邮件。
|
||||
此邮件属系统自动发出,无需回复。
|
||||
上海展影医疗科技有限公司"
|
||||
};
|
||||
using (var smtp = new MailKit.Net.Smtp.SmtpClient())
|
||||
{
|
||||
@@ -207,7 +160,7 @@ namespace IRaCIS.Application.Services
|
||||
var code = verificationCode.ToString();
|
||||
_ = _verificationCodeRepository.AddAsync(new VerificationCode()
|
||||
{
|
||||
CodeType = 0,
|
||||
CodeType = VerifyType.Email,
|
||||
HasSend = true,
|
||||
Code = code,
|
||||
UserId = Guid.Empty,//此时不知道用户
|
||||
@@ -230,6 +183,59 @@ namespace IRaCIS.Application.Services
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public async Task SendMail(Guid userId, string userName, string emailAddress, int verificationCode)
|
||||
{
|
||||
|
||||
|
||||
var messageToSend = new MimeMessage();
|
||||
//发件地址
|
||||
messageToSend.From.Add(new MailboxAddress("GRR", "iracis_grr@163.com"));
|
||||
//收件地址
|
||||
messageToSend.To.Add(new MailboxAddress(userName, emailAddress));
|
||||
//主题
|
||||
messageToSend.Subject = "Reset PassWord (Verification Code)";
|
||||
|
||||
messageToSend.Body = new TextPart("plain")
|
||||
{
|
||||
Text = $@"Hey {userName},you are resetting your password via email. The verification code is: {verificationCode}, which is valid within 3 minutes. If it is not your own operation, please ignore it!
|
||||
|
||||
-- GRR"
|
||||
};
|
||||
using (var smtp = new MailKit.Net.Smtp.SmtpClient())
|
||||
{
|
||||
smtp.MessageSent += (sender, args) =>
|
||||
{
|
||||
// args.Response
|
||||
var code = verificationCode.ToString();
|
||||
_ = _verificationCodeRepository.AddAsync(new VerificationCode()
|
||||
{
|
||||
CodeType = 0,
|
||||
HasSend = true,
|
||||
Code = code,
|
||||
UserId = userId,
|
||||
ExpirationTime = DateTime.Now.AddMinutes(3)
|
||||
}).Result;
|
||||
_ = _verificationCodeRepository.SaveChangesAsync().Result;
|
||||
|
||||
};
|
||||
|
||||
smtp.ServerCertificateValidationCallback = (s, c, h, e) => true;
|
||||
|
||||
await smtp.ConnectAsync("smtp.163.com", 25, SecureSocketOptions.StartTls);
|
||||
|
||||
await smtp.AuthenticateAsync("iracis_grr@163.com", "XLWVQKZAEKLDWOAH");
|
||||
|
||||
await smtp.SendAsync(messageToSend);
|
||||
|
||||
await smtp.DisconnectAsync(true);
|
||||
|
||||
}
|
||||
}
|
||||
public async Task SendEmailForExternalUser(string emailAddress, string verificationCode)
|
||||
{
|
||||
var messageToSend = new MimeMessage();
|
||||
|
||||
Reference in New Issue
Block a user