public ActionResult ResetPassword(string id, PasswordResetContainer resetContainer) { var authKey = Guid.Empty; if (!String.IsNullOrWhiteSpace(id) && !Guid.TryParse(id, out authKey)) { return(StatusCode(403)); } var user = _userService.GetUserByAuhtorizationKey(authKey); resetContainer.IsValidUser = true; if (resetContainer.Password != resetContainer.PasswordRetype) { ModelState.AddModelError("PasswordRetype", Resources.RetypePasswordMustMatch); } string errorMessage; _userService.IsPasswordValid(resetContainer.Password, out errorMessage); if (!String.IsNullOrWhiteSpace(errorMessage)) { ModelState.AddModelError("Password", errorMessage); } if (!ModelState.IsValid) { return(View(resetContainer)); } _userService.ResetPassword(user, resetContainer.Password, HttpContext.Connection.RemoteIpAddress.ToString()); return(RedirectToAction("ResetPasswordSuccess")); }
public ActionResult ResetPassword(string id) { var authKey = Guid.Empty; if (!String.IsNullOrWhiteSpace(id) && !Guid.TryParse(id, out authKey)) { return(StatusCode(403)); } var user = _userService.GetUserByAuhtorizationKey(authKey); var container = new PasswordResetContainer(); if (user == null) { container.IsValidUser = false; } else { container.IsValidUser = true; } return(View(container)); }
public ActionResult ResetPassword(string id, PasswordResetContainer resetContainer) { var authKey = Guid.Empty; if (!String.IsNullOrWhiteSpace(id) && !Guid.TryParse(id, out authKey)) { this.Forbidden("Forbidden", null); } var user = _userService.GetUserByAuhtorizationKey(authKey); resetContainer.IsValidUser = true; if (resetContainer.Password != resetContainer.PasswordRetype) { ModelState.AddModelError("PasswordRetype", Resources.RetypePasswordMustMatch); } _userService.IsPasswordValid(resetContainer.Password, ModelState); if (!ModelState.IsValid) { return(View(resetContainer)); } _userService.ResetPassword(user, resetContainer.Password, HttpContext); return(RedirectToAction("ResetPasswordSuccess")); }