public ActionResult ChangePass(ChangePass changePass) { if (ModelState.IsValid) { if (Session["cp_Login"] != null && Session["cp_Pass"] != null) { var userPassData = passwordHelper.CryptPassword(changePass.Password); userPassData.Login = Session["cp_Login"].ToString(); try { var user = dataHelper.ChangePass(userPassData); if (user != null) { FormsAuthentication.SetAuthCookie(user.Login, true); return(View("PassChangeSuccess")); } else { return(View("Error", new Error() { ExDescription = "Error to find User!" })); } } catch (ValidationException ve) { return(View("UserError", ve)); } } } return(View(changePass)); }
public ActionResult ChangePassRegistered(ChangePassRegistered passData) { try { var user = dataHelper.GetUserData(User.Identity.Name); ViewBag.User = user; if (ModelState.IsValid) { var userPassData = dataHelper.GetPasswordData(user.Login); if (passwordHelper.CheckPassword(passData.OldPassword, userPassData)) { userPassData = passwordHelper.CryptPassword(passData.ConfirmPassword); userPassData.Login = user.Login; dataHelper.ChangePass(userPassData); return(RedirectToAction("Index")); } else { ModelState.AddModelError("OldPassword", "Не верный пароль"); return(View(passData)); } } return(View(passData)); } catch (Exception ex) { logger.ErrorMessage("305", ex); return(View("Error", new Error() { ExDescription = ex.Message })); } }