public async Task <IActionResult> ResetPasswordConfirm(PasswordVM model) { string token = TempData["token"].ToString(); string id = TempData["userid"].ToString(); AppUser user = await Usermanager.FindByIdAsync(id); if (user != null) { IdentityResult result = await Usermanager.ResetPasswordAsync(user, token, model.Password); if (result.Succeeded) { await Usermanager.UpdateSecurityStampAsync(user); TempData["passwordResetInfo"] = "sifreniz basariyla yenilendi"; } else { AddErrors(result); } } else { ModelState.AddModelError("", "boyle biri yok"); } return(View()); }
public async Task <IActionResult> ResetPassword(ResetPasswordViewModel model) { if (ModelState.IsValid) { // Find the user by email var user = await Usermanager.FindByEmailAsync(model.Email); if (user != null) { // reset the user password var result = await Usermanager.ResetPasswordAsync(user, model.Token, model.Password); if (result.Succeeded) { return(View("ResetPasswordConfirmation")); } // Display validation errors. For example, password reset token already // used to change the password or password complexity rules not met foreach (var error in result.Errors) { ModelState.AddModelError("", error.Description); } return(View(model)); } // To avoid account enumeration and brute force attacks, don't // reveal that the user does not exist return(View("ResetPasswordConfirmation")); } // Display validation errors if model state is not valid return(View(model)); }