Ejemplo n.º 1
0
        public ActionResult ChangePassword(ChangePassword model)
        {
            if (model.Password == model.ConfirmPassword)
            {
                User user = db.Users.Where(u => u.UserID == Helpers.CurrentUserID).First();
                user.Password = Helpers.EncodePasswordToBase64(model.Password);
                user.ResetPasswordCode = null;
                db.SaveChanges();

                Session["hpmessage"] = "Your password has been successfully changed.";

                return Redirect("~/");
            }

            ModelState.AddModelError("", "Passwords did not match.");
            return View(model);
        }
Ejemplo n.º 2
0
        public ActionResult ResetPassword(Guid id, ChangePassword model)
        {
            if (model.Password == model.ConfirmPassword)
            {
                string resetCode = id.ToString();

                User user = db.Users.Where(u => u.ResetPasswordCode == resetCode).First();
                user.Password = Helpers.EncodePasswordToBase64(model.Password);
                user.ResetPasswordCode = null;
                db.SaveChanges();

                Session["hpmessage"] = "Your password has been successfully reset.";

                return Redirect("~/");
            }

            ModelState.AddModelError("", "Passwords did not match.");
            return View(model);
        }