Getting info on email sent
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
|
||||
using System.Threading.Tasks;
|
||||
using Yavsc.Abstract.Manage;
|
||||
|
||||
namespace Yavsc.Services
|
||||
{
|
||||
@ -13,6 +14,6 @@ namespace Yavsc.Services
|
||||
/// <param name="subject">email subject</param>
|
||||
/// <param name="message">message</param>
|
||||
/// <returns>the message id</returns>
|
||||
Task<string> SendEmailAsync(string username, string email, string subject, string message);
|
||||
Task<EmailSentViewModel> SendEmailAsync(string username, string email, string subject, string message);
|
||||
}
|
||||
}
|
||||
|
10
Yavsc.Abstract/Manage/EmailSentViewModel.cs
Normal file
10
Yavsc.Abstract/Manage/EmailSentViewModel.cs
Normal file
@ -0,0 +1,10 @@
|
||||
namespace Yavsc.Abstract.Manage
|
||||
{
|
||||
public class EmailSentViewModel
|
||||
{
|
||||
public string EMail { get; set; }
|
||||
public string MessageId { get; set; }
|
||||
public bool Sent { get; set; }
|
||||
public string ErrorMessage { get; set; }
|
||||
}
|
||||
}
|
@ -16,6 +16,7 @@ using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using Yavsc.Server.Helpers;
|
||||
using Microsoft.Extensions.OptionsModel;
|
||||
using Yavsc.Abstract.Manage;
|
||||
|
||||
namespace Yavsc.Services
|
||||
{
|
||||
@ -98,9 +99,9 @@ namespace Yavsc.Services
|
||||
return await NotifyEvent<HairCutQueryEvent>(registrationIds, ev);
|
||||
}
|
||||
|
||||
public Task<string> SendEmailAsync(string username, string email, string subject, string message)
|
||||
public Task<EmailSentViewModel> SendEmailAsync(string username, string email, string subject, string message)
|
||||
{
|
||||
string messageId=null;
|
||||
EmailSentViewModel model = new EmailSentViewModel{ EMail = email };
|
||||
try
|
||||
{
|
||||
MimeMessage msg = new MimeMessage();
|
||||
@ -123,14 +124,16 @@ namespace Yavsc.Services
|
||||
smtpSettings.Port,
|
||||
SecureSocketOptions.None);
|
||||
sc.Send(msg);
|
||||
messageId = msg.MessageId;
|
||||
model.MessageId = msg.MessageId;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Task.FromResult<string>(null);
|
||||
model.Sent = false;
|
||||
model.ErrorMessage = ex.Message;
|
||||
return Task.FromResult<EmailSentViewModel>(model);
|
||||
}
|
||||
return Task.FromResult(messageId);
|
||||
return Task.FromResult(model);
|
||||
}
|
||||
|
||||
public Task<bool> ValidateAsync(string purpose, string token, UserManager<ApplicationUser> manager, ApplicationUser user)
|
||||
|
@ -20,6 +20,7 @@ using Newtonsoft.Json;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
using Yavsc.Abstract.Manage;
|
||||
using Yavsc.Helpers;
|
||||
|
||||
public class AccountController : Controller
|
||||
@ -247,11 +248,11 @@ namespace Yavsc.Controllers
|
||||
public async Task<IActionResult> SendEMailForConfirm()
|
||||
{
|
||||
var user = await _userManager.FindByIdAsync(User.GetUserId());
|
||||
ViewBag.EmailSent = await SendEMailForConfirmAsync(user);
|
||||
return View("ConfirmEmailSent",user.Email);
|
||||
var model = await SendEMailForConfirmAsync(user);
|
||||
return View("ConfirmEmailSent",model);
|
||||
}
|
||||
|
||||
private async Task<string> SendEMailForConfirmAsync(ApplicationUser user)
|
||||
private async Task<EmailSentViewModel> SendEMailForConfirmAsync(ApplicationUser user)
|
||||
{
|
||||
var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);
|
||||
var callbackUrl = Url.Action("ConfirmEmail", "Account",
|
||||
|
@ -1,4 +1,4 @@
|
||||
@model string
|
||||
@model Yavsc.Abstract.Manage.EmailSentViewModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "S'il vous plait, veuillez confirmer votre adresse e-mail";
|
||||
@ -7,7 +7,7 @@
|
||||
<h2>@ViewData["Title"].</h2>
|
||||
<div>
|
||||
<p>
|
||||
Un message vient de vous être envoyé, à votre adresse e-mail ( @Model , id:@ViewBag.EmailSent ),
|
||||
Un message vient de vous être envoyé, à votre adresse e-mail ( @Model.Email , id:@Model.MessageId ),
|
||||
Veuillez s’il vous plait confirmer cette adresse de courrier en utilisant le lien hyper-texte qui s'y trouve.
|
||||
</p>
|
||||
</div>
|
||||
|
@ -1 +1 @@
|
||||
21-beta5
|
||||
21-beta6
|
||||
|
Reference in New Issue
Block a user