@page "/Account/ForgotPassword" @using System.ComponentModel.DataAnnotations @using System.Text @using System.Text.Encodings.Web @using Aaru.Server.New.Data @using Microsoft.AspNetCore.Identity @using Microsoft.AspNetCore.WebUtilities @inject UserManager UserManager @inject IEmailSender EmailSender @inject NavigationManager NavigationManager @inject IdentityRedirectManager RedirectManager Forgot your password?

Forgot your password?

Enter your email.


@code { [SupplyParameterFromForm] private InputModel Input { get; set; } = new(); private async Task OnValidSubmitAsync() { ApplicationUser? user = await UserManager.FindByEmailAsync(Input.Email); if(user is null || !await UserManager.IsEmailConfirmedAsync(user)) { // Don't reveal that the user does not exist or is not confirmed RedirectManager.RedirectTo("Account/ForgotPasswordConfirmation"); } // For more information on how to enable account confirmation and password reset please // visit https://go.microsoft.com/fwlink/?LinkID=532713 string code = await UserManager.GeneratePasswordResetTokenAsync(user); code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code)); string callbackUrl = NavigationManager.GetUriWithQueryParameters(NavigationManager.ToAbsoluteUri("Account/ResetPassword").AbsoluteUri, new Dictionary { ["code"] = code }); await EmailSender.SendPasswordResetLinkAsync(user, Input.Email, HtmlEncoder.Default.Encode(callbackUrl)); RedirectManager.RedirectTo("Account/ForgotPasswordConfirmation"); } private sealed class InputModel { [Required] [EmailAddress] public string Email { get; set; } = ""; } }