public IActionResult ResetPassword([FromQuery] string username, [FromQuery] string token) { if (User.Identity.IsAuthenticated) { return(RedirectToAction(nameof(AccountController.Login), "Account")); } if (string.IsNullOrWhiteSpace(username) || string.IsNullOrWhiteSpace(token)) { ModelState.AddModelError( nameof(CommonErrors.ErrorInvalidNameOrToken), string.Format(CommonErrors.ErrorInvalidNameOrToken, username, token)); } var model = new ResetPasswordModel { Username = username, Token = token }; return(View(nameof(ResetPassword), model)); }
public async Task <ActionResult> ResetPassword(ResetPasswordModel model, string signin) { 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", new { signin = signin })); } var result = await _userManager.ResetPasswordAsync(user.Id, model.Code, model.Password); if (result.Succeeded) { return(RedirectToAction("ResetPasswordConfirmation", "Account", new { signin = signin })); } AddErrors(result); return(View()); }
public async Task <IActionResult> ResetPassword([FromForm] ResetPasswordModel request) { if (User.Identity.IsAuthenticated) { return(RedirectToAction(nameof(AccountController.Login), "Account")); } if (!ModelState.IsValid) { return(View(nameof(ResetPassword), request)); } var result = await _mediator.Send(Application.PasswordManagement.ResetPassword.Command.New(request.Username, request.Password, request.Token)); if (!result.Succeeded) { AddErrors(result); return(View(nameof(ResetPassword), request)); } TempData["UserFeedback"] = PasswordRecovery.ResetPasswordComplete; return(RedirectToAction(nameof(AccountController.Login), "Account")); }