public HttpResponseMessage ResetPassword([FromBody] ResetPasswordModel resetPasswordModel) { if (!ModelState.IsValid) { throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.BadRequest)); } HttpResponseMessage response; IUser user; // Reset the password try { user = accountBusiness.ResetPassword(resetPasswordModel.NewPassword, resetPasswordModel.ResetToken); } catch (InvalidPasswordResetTokenException ex) { response = Request.CreateResponse(HttpStatusCode.NotFound); response.Headers.Location = new Uri(Request.RequestUri, "/api/acount/resetpassword"); return(response); } catch (ExpiredPasswordResetTokenException ex) { response = Request.CreateResponse(HttpStatusCode.Gone); response.Headers.Location = new Uri(Request.RequestUri, "/api/acount/resetpassword"); return(response); } response = Request.CreateResponse(HttpStatusCode.OK, user); response.Headers.Location = new Uri(Request.RequestUri, "/api/acount/" + user.Id); return(response); }
public void Should_Validate_PasswordResetToken_Is_Genuine() { // Arrange repository.GetCredentialsByResetToken(Arg.Any <string>()).Returns((ICredentials)null); // Act accountBusiness.ResetPassword("NewPassword", "resetToken"); }
public ActionResult Reset(LoginModel model) { List <LoginModel> _model = new List <LoginModel>(); if (ModelState.IsValid) { model.username = Session["UserID"].ToString(); _model = _objIAccountBusiness.ResetPassword(model).ToList(); } else { TempData["ErrorMessage"] = "Some unknown error has occured. Please try again."; } return(Json(_model, JsonRequestBehavior.AllowGet)); }