public ActionResult ChangePassword(ChangePasswordModel model) { if (ModelState.IsValid) { // Throws exception error bool changePasswordSucceeded; try { changePasswordSucceeded = model.ChangePassword(model.OldPassword, model.NewPassword); } catch (Exception) { changePasswordSucceeded = false; } if (changePasswordSucceeded) { return(RedirectToAction("ChangePasswordSuccess")); } else { ModelState.AddModelError("", "The current password is incorrect or the new password is invalid."); } } // Redisplay Form return(View(model)); }
public ActionResult ChangePassword(ChangePasswordModel model) { if (ModelState.IsValid) { bool changePasswordSucceeded; try { changePasswordSucceeded = model.ChangePassword(model.OldPassword, model.NewPassword); } catch (Exception) { changePasswordSucceeded = false; } if (changePasswordSucceeded) { return(RedirectToAction("ChangePasswordSuccess")); } else { ModelState.AddModelError("", "The current password is Incorrect."); } } // If we got this far, something failed, redisplay form return(View(model)); }
public async Task <ActionResult> Post(ChangePassword model) { if (!ModelState.IsValid) { return(this.InvalidModelState()); } bool result = await ChangePasswordModel.ChangePassword(model, this.RemoteUser); return(this.Ok(result)); }
/// <summary> /// The login form for the admin site. Will auto redirect if logged in. /// </summary> /// <returns></returns> public ActionResult ChangePassword(ChangePasswordModel model) { // The user shouldn't be here if (UserUtils.CurrentUser == null) { // log them in Response.Redirect("~/Admin"); } // set the user before trying to change the password model.SetUser(UserUtils.CurrentUser, db); // this will only change the password if someone actually passes the necessary strings model.ChangePassword(); // pass the model return(View(model)); }
public ActionResult ChangePassword(ChangePasswordModel item) { try { if (new ChangePasswordModel().GetUserByUserIDAndPassword(item.UserIDChange, SqlHelper.GetMd5Hash(item.OldPass))) { item.RepeatNewPass = SqlHelper.GetMd5Hash(item.RepeatNewPass); item.ChangePassword(); return(Json(new { success = true, message = "Successful !!!" })); } return(Json(new { success = false, message = "Password incorrect" })); } catch (Exception e) { return(Json(new { success = false, message = e.Message })); } }
public ActionResult ChangePassword(ChangePasswordModel item) { try { if (new ChangePasswordModel().GetUserByUserNameAndPassword(item.UserNameChange, SqlHelper.GetMd5Hash(item.OldPass))) { item.RepeatNewPass = SqlHelper.GetMd5Hash(item.RepeatNewPass); item.ChangePassword(); return(Json(new { success = true, message = "Thành công" })); } return(Json(new { success = false, message = "Mật khẩu không đúng" })); } catch (Exception e) { return(Json(new { success = false, message = e.Message })); } finally { } }
public void ChangePassword_ApiCalledCorrectly() { _fakeApi.ChangePassword("old", "new", "new").Returns(true); Assert.IsTrue(_uut.ChangePassword("old", "new")); }
public bool ChangePassword([FromBody] ChangePasswordModel password) { return(password.ChangePassword(OrnamentContext.MemberShip.CurrentUser(), _memberShipFactory.CreateUserDao())); }