in Application/UI/mvc-frontend/ImageRecognition/Areas/Identity/Pages/Account/ResetPassword.cshtml.cs [35:55]
public async Task<IActionResult> OnPostAsync(string returnUrl = null)
{
if (!ModelState.IsValid) return Page();
returnUrl = returnUrl ?? Url.Content("~/");
var user = await _userManager.FindByEmailAsync(Input.Email);
if (user == null) throw new InvalidOperationException("Unable to retrieve user.");
var result = await _userManager.ResetPasswordAsync(user, Input.ResetToken, Input.NewPassword);
if (result.Succeeded)
{
_logger.LogInformation("Password reset for user with ID '{UserId}'.", user.UserID);
return LocalRedirect(returnUrl);
}
_logger.LogInformation("Unable to rest password for user with ID '{UserId}'.", user.UserID);
foreach (var item in result.Errors) ModelState.AddModelError(item.Code, item.Description);
return Page();
}