public ActionResult ChangePassword(User user, string password, string newpassword, string confirmpassword) { var session = (UserLogin)Session[GamingShop.Common.CommonConstants.USER_SESSION]; long id = session.UserID; var userController = new MoUserController(); ViewBag.Success = false; if (user.Password == password) { if (newpassword == confirmpassword) { var encryptednewpassword = Encryptor.MD5Hash(newpassword); user.Password = encryptednewpassword; var result = userController.ChangePassword(id, user); if (result) { return(RedirectToAction("ChangePassword/" + session.UserID, "User")); } } else { ModelState.AddModelError("", "Confirm password is wrong"); } } else { ModelState.AddModelError("", "Change password not succeeded"); } return(View("ChangePassword")); }
public ActionResult NewPassword(string newpassword, string confirmpassword) { if (ModelState.IsValid) { var forgotpasswordsession = (ForgotPasswordModel)Session[GamingShop.Common.CommonConstants.ForgotPasswordSession]; var userController = new MoUserController(); var user = userController.GetByMail(forgotpasswordsession.Email); if (newpassword == confirmpassword) { var encryptednewpassword = Encryptor.MD5Hash(newpassword); user.Password = encryptednewpassword; var result = userController.ChangePassword(user.ID, user); if (result) { return(View("Success")); } } else { ModelState.AddModelError("", "Change password not succeeded"); return(View("NewPassword")); } } return(View("Success")); }