public ActionResult ResetPassword(ResetPasswordModel model) { if (ModelState.IsValid) { try { _membershipService.ChangePassword(model.Token, model.NewPassword); ViewData.AddRequestSuccessMessage(SuccessMessagesResources.PasswordChangedInfo); return(View()); } catch (InvalidPasswordTokenException ex) { throw new HttpException((int)HttpStatusCode.NotFound, "not found", ex); } catch (InvalidPasswordException) { ModelState.AddModelError("NewPassword", ValidationResources.RegInvalidPassword); } catch (UserNotExistsException) { ModelState.AddModelError("profile", ValidationResources.AccountNotFound); return(View()); } catch (StaleUserException) { ModelState.AddModelError("profile", ValidationResources.AccountStalled); return(View()); } } return(View(model)); }
public ActionResult ResetPasswordRequest(ResetPasswordRequestModel model) { if (ModelState.IsValid) { try { _membershipService.RequestPasswordReset(model.Email, BaseSiteUrl(), token => FullUrlForAction("ResetPassword", "Account", new { token })); ViewData.AddRequestSuccessMessage(SuccessMessagesResources.ResetPasswdRequestSentInfo); return(View()); } catch (UserNotExistsException) { ModelState.AddModelError("email", ValidationResources.EmailNotFoundError); } catch (DeliveryException ex) { Logger.Error(ex); ModelState.AddModelError("delivery", ValidationResources.ResetInstructionSendingFailedError); } } if (model == null) { model = new ResetPasswordRequestModel(); } return(View(model)); }