public ActionResult ChangePassword(string email = "", string oldPassword = "", string newPassword = "", string confirmPassword = "")
 {
     if (string.IsNullOrEmpty(oldPassword))
     {
         ModelState.AddModelError("oldpassword", "Old Password expected!");
     }
     if (string.IsNullOrEmpty(newPassword))
     {
         ModelState.AddModelError("newpassword", "New Password expected!");
     }
     if (string.IsNullOrEmpty(confirmPassword))
     {
         ModelState.AddModelError("confirmpassword", "Confirm Password expected!");
     }
     if (UserAccountBLL.Authorize(email, Helper.EncodeMD5(oldPassword)
                                  , UserAccountTypes.Employee) == null)
     {
         ModelState.AddModelError("authorize", "Old Password does not match!");
     }
     if (oldPassword == newPassword)
     {
         ModelState.AddModelError("different", "Old Password must be different New Password!");
     }
     if (newPassword != confirmPassword)
     {
         ModelState.AddModelError("match", "New Password can't be different Confirm Password!");
     }
     if (!ModelState.IsValid)
     {
         return(View());
     }
     newPassword = Helper.EncodeMD5(newPassword);
     UserAccountBLL.ChangePassword(email, newPassword, UserAccountTypes.Employee);
     return(RedirectToAction("Index", "Dashboard"));
 }
Exemplo n.º 2
0
 public ActionResult ForgotPassword(string email = "", string pwn = "", string confirmpw = "")
 {
     ViewBag.Email = email;
     if (pwn.Equals(confirmpw))
     {
         if (EmployeeBLL.CheckEmail(email) != 0)
         {
             UserAccountBLL.ChangePassword(Encode.EncodeMD5(pwn), email);
             return(RedirectToAction("SignIn", "Account"));
         }
         else
         {
             ModelState.AddModelError("Messege", "Email không tồn tại!");
             return(View());
         }
     }
     else
     {
         ModelState.AddModelError("Messege", "Mật Khẩu không khớp!");
         return(View());
     }
 }
Exemplo n.º 3
0
 public ActionResult ChangePwd(string email = "", string password = "", string newpassword1 = "", string newpassword2 = "")
 {
     try
     {
         Employee acc = this.getCurrentUser();
         if (email == "")
         {
             ModelState.AddModelError("Email", "Email is required");
         }
         else if (email != acc.Email)
         {
             ModelState.AddModelError("Email", "Email isn't correct");
         }
         if (acc.Password != LiteCommerce.Admin.Codes.EncodeMD5.EncodesMD5(password))
         {
             ModelState.AddModelError("Password", "Password isn't correct");
         }
         if (newpassword1.Length < 8)
         {
             ModelState.AddModelError("NewPassword1", "New password length must be greater or equal 8");
         }
         else if (newpassword1 != newpassword2)
         {
             ModelState.AddModelError("NewPassword1", "New password are not same");
             ModelState.AddModelError("NewPassword2", "New password are not same");
         }
         if (ModelState.IsValid)
         {
             int rs = UserAccountBLL.ChangePassword(acc.EmployeeID + "", LiteCommerce.Admin.Codes.EncodeMD5.EncodesMD5(newpassword1), UserAccountTypes.Employee);
             ViewBag.MessageSuccess = "Password changed";
         }
     }
     catch (Exception e)
     {
         ModelState.AddModelError(string.Empty, "Error: " + e.Message);
     }
     return(View());
 }
Exemplo n.º 4
0
        public ActionResult ChangePassword(string pw = "", string pwn = "", string confirmpw = "")
        {
            WebUserData userData = User.GetUserData();
            Employee    employee = CataLogBLL.GetEmployee(Convert.ToInt32(userData.UserID));

            if (employee.Password.Equals(MaHoaMD5Hepler.EncodeMD5(pw)))
            {
                if (pwn.Equals(confirmpw))
                {
                    UserAccountBLL.ChangePassword(MaHoaMD5Hepler.EncodeMD5(pwn), employee.Email);
                    return(RedirectToAction("Index"));
                }
                else
                {
                    ModelState.AddModelError("MatKhau", "Mật khẩu không khớp!");
                    return(View());
                }
            }
            else
            {
                ModelState.AddModelError("MatKhauMoi", "Mật Khẩu không đúng!");
                return(View());
            }
        }