in Source/WebApp-IdentityProvider-MFA/Areas/Identity/Pages/Account/Manage/Email.cshtml.cs [140:171]
public async Task<IActionResult> OnPostSendVerificationEmailAsync()
{
var user = await _userManager.GetUserAsync(User);
if (user == null)
{
return NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'.");
}
if (!ModelState.IsValid)
{
await LoadAsync(user);
return Page();
}
var userId = await _userManager.GetUserIdAsync(user);
var email = await _userManager.GetEmailAsync(user);
var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);
code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code));
var callbackUrl = Url.Page(
"/Account/ConfirmEmail",
pageHandler: null,
values: new { area = "Identity", userId, code },
protocol: Request.Scheme);
await _emailSender.SendEmailAsync(
email,
"Confirmez votre adresse mail",
$"Veuillez confirmer votre compte en <a href='{HtmlEncoder.Default.Encode(callbackUrl)}'>cliquant ici</a>."
);
StatusMessage = "Le mail de confirmation a été envoyé. Consultez votre boite mail.";
return RedirectToPage();
}