public ActionResult ChangePassword(ChangePasswordModel model) { if (ModelState.IsValid) { string HashPassword = MPHash.GetPassWordMD5Hash(model.OldPassword); //hash password string HashNewPassword = MPHash.GetPassWordMD5Hash(model.NewPassword); if (MembershipService.ChangePassword(User.Identity.Name, HashPassword, HashNewPassword)) { TransactionLogViewModel.AddLog(User.Identity.Name + " has changed the password successfully!", DateTime.Now); return RedirectToAction("ChangePasswordSuccess", "Account"); } else { TransactionLogViewModel.AddLog(User.Identity.Name + " change the password unsuccessfully", DateTime.Now); ModelState.AddModelError("", LangText.GetText("THE_CURRENT_PASSWORD_IS_INCORRECT_OR_THE_NEW_PASSWORD_IS_INVALID")); } } // If we got this far, something failed, redisplay form ViewData["PasswordLength"] = MembershipService.MinPasswordLength; return View(model); }
public ActionResult ChangePassword(ChangePasswordModel model) { if (ModelState.IsValid) { if (MembershipService.ChangePassword(User.Identity.Name, model.OldPassword, model.NewPassword)) { return RedirectToAction("ChangePasswordSuccess"); } else { ModelState.AddModelError("", "The current password is incorrect or the new password is invalid."); } } // If we got this far, something failed, redisplay form ViewData["PasswordLength"] = MembershipService.MinPasswordLength; return View(model); }