public async Task OnPostAsync()

in Source/WebApp-IdentityProvider-MFA/Areas/Identity/Pages/Account/ResendEmailConfirmation.cshtml.cs [45:76]


        public async Task<IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return Page();
            }

            var user = await _userManager.FindByEmailAsync(Input.Email);
            if (user == null)
            {
                // We do not indicate that the user does not exists to avoid information leak
                ModelState.AddModelError(string.Empty, "Le mail de confirmation a été renvoyé. Consultez votre boite mail.");
                return Page();
            }

            var userId = await _userManager.GetUserIdAsync(user);
            var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);
            code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code));
            var callbackUrl = Url.Page(
                "/Account/ConfirmEmail",
                pageHandler: null,
                values: new { userId, code },
                protocol: Request.Scheme);
            await _emailSender.SendEmailAsync(
                Input.Email,
                "Confirmez votre adresse mail",
                $"Veuillez confirmer votre compte en <a href='{HtmlEncoder.Default.Encode(callbackUrl)}'>cliquant ici</a>."
                );

            ModelState.AddModelError(string.Empty, "Le mail de confirmation a été renvoyé. Consultez votre boite mail.");
            return Page();
        }