@page "/forgot" @inject IAccountManagement Acct

Forgot Password

@if (isReset) {

Your password has been reset. Log in with your new password any time.

} else if (isCodeSent) {

Look for an email from shogi@lucaserver.space with a reset code and fill out the form.

}
@if (errorList.Length > 0) { } @if (!isCodeSent) { } else { }
@code { private bool isCodeSent = false; private bool isReset = false; private string email = string.Empty; private string code = string.Empty; private string newPassword = string.Empty; private string confirmPassword = string.Empty; private string[] errorList = []; async Task SendResetCode() { if (string.IsNullOrWhiteSpace(email)) { errorList = ["Email is required"]; return; } var response = await Acct.RequestPasswordReset(email); isCodeSent = response.IsSuccessStatusCode; if (!response.IsSuccessStatusCode) { errorList = [await response.Content.ReadAsStringAsync()]; } } async Task ChangePassword() { var errors = new List(5); if (string.IsNullOrWhiteSpace(email)) { errors.Add("Email is required"); } if (string.IsNullOrWhiteSpace(code)) { errors.Add("Reset code is required"); } if (string.IsNullOrWhiteSpace(newPassword)) { errors.Add("New password is required"); } if (!newPassword.Equals(confirmPassword)) { errors.Add("Your new password and confirm password do not match"); } var result = await Acct.ChangePassword(email, code, newPassword); if (result.Succeeded) { isReset = true; ClearFormFields(); } else { errorList = result.ErrorList; } } void ClearFormFields() { email = code = newPassword = confirmPassword = string.Empty; } }