Exemplo n.º 1
0
        public ActionResult ChangePwd(string oldPassword, string newPassword, string reNewPassword)
        {
            WebUserData userData = User.GetUserData();
            string      email    = Convert.ToString(userData.Email);

            if (string.IsNullOrEmpty(oldPassword))
            {
                ModelState.AddModelError("OldPassword", "OldPassword is required");
            }
            else
            {
                if (!AccountBLL.Account_CheckPass(oldPassword, email))
                {
                    ModelState.AddModelError("OldPassword", "Old password incorrect");
                }
                ViewBag.OldPassword = oldPassword;
            }
            if (string.IsNullOrEmpty(newPassword))
            {
                ModelState.AddModelError("NewPassword", "NewPassword is required");
            }
            else
            {
                if (newPassword.Length < 6)
                {
                    ModelState.AddModelError("NewPassword", "Password must over 6 characters");
                }
                ViewBag.NewPassword = newPassword;
            }
            if (string.IsNullOrEmpty(reNewPassword))
            {
                ModelState.AddModelError("ReNewPassword", "ReNewPassword is required");
            }
            else
            {
                if (!newPassword.Equals(reNewPassword))
                {
                    ModelState.AddModelError("ReNewPassword", "The new password does not match the old password");
                }
                ViewBag.ReNewPassword = reNewPassword;
            }
            if (!ModelState.IsValid)
            {
                return(View());
            }
            if (UserAccountBLL.Account_ChangePwd(newPassword, email))
            {
                ModelState.AddModelError("success", "Cập nhật thành công");
                ViewBag.OldPassword   = "";
                ViewBag.NewPassword   = "";
                ViewBag.ReNewPassword = "";
                return(View());
            }
            ModelState.AddModelError("error", "Cập nhật không thành công");
            return(RedirectToAction("ChangePwd"));
        }
Exemplo n.º 2
0
 public ActionResult ChangeForgotPassword(string Email = "", string Password = "")
 {
     if (AccountBLL.Account_Get(Email) == null)
     {
         ModelState.AddModelError("error", "Cập nhật không thành công");
         return(RedirectToAction("ChangePwd"));
     }
     if (UserAccountBLL.Account_ChangePwd(Password, Email))
     {
         return(RedirectToAction("Index"));
     }
     return(RedirectToAction("Index"));
 }