public async Task<ActionResult> ResetPassword(ResetPasswordViewModel model) { if (this.ModelState.IsValid) { var user = await this.UserManager.FindByNameAsync(model.Email); if (user == null) { this.ModelState.AddModelError("", "No user found."); return this.View(); } IdentityResult result = await this.UserManager.ResetPasswordAsync(user.Id, model.Code, model.Password); if (result.Succeeded) { return this.RedirectToAction("ResetPasswordConfirmation", "Account"); } else { this.AddErrors(result); return this.View(); } } // If we got this far, something failed, redisplay form return this.View(model); }
public async Task<ActionResult> ResetPassword(ResetPasswordViewModel model) { if (!ModelState.IsValid) { return View(model); } var user = await UserManager.FindByNameAsync(model.Email); if (user == null) { // Don't reveal that the user does not exist return RedirectToAction("ResetPasswordConfirmation", "Account"); } var result = await UserManager.ResetPasswordAsync(user.Id, model.Code, model.Password); if (result.Succeeded) { return RedirectToAction("ResetPasswordConfirmation", "Account"); } AddErrors(result); return View(); }