public JsonResult ResetPasswordInAdminPage(int userId, string current_password, string password)
        {
            bool        check;
            UserAccount userAccount = db.UserAccounts.Where(ua => ua.UserId == userId).FirstOrDefault();

            if (userAccount != null)
            {
                UserAccountController uac  = new UserAccountController();
                string userPasswordDecrypt = uac.DecryptPassword(userAccount.Password);
                if (current_password == userPasswordDecrypt)
                {
                    string passwordEncrypt = uac.EncryptPassword(password);
                    userAccount.Password = passwordEncrypt;
                    db.SaveChanges();
                    check = true;
                }
                else
                {
                    check = false;
                }
            }
            else
            {
                check = false;
            }
            return(Json(check));
        }
Пример #2
0
        public JsonResult CheckLogin(string username, string password)
        {
            UserAccountController uac = new UserAccountController();
            string      ePassword     = uac.EncryptPassword(password);
            UserAccount userCheck     = db.UserAccounts.Where(ua => ua.UserName == username && ua.Password == ePassword).FirstOrDefault();

            if (userCheck != null)
            {
                bool check = true;
                return(Json(check));
            }
            else
            {
                bool check = false;
                return(Json(check));
            }
        }
Пример #3
0
        public ActionResult ResetPassword(int userId, string randomPassword, string password)
        {
            UserAccount           userAccount = db.UserAccounts.Where(ua => ua.UserId == userId).FirstOrDefault();
            UserAccountController uac         = new UserAccountController();
            string ePassword = uac.EncryptPassword(password);

            userAccount.Password = ePassword;
            int check = db.SaveChanges();

            if (check > 0)
            {
                return(RedirectToAction("Index"));
            }
            else
            {
                return(View("ResetPassword"));
            }
        }
Пример #4
0
 public ActionResult Index(string username, string password)
 {
     if (ModelState.IsValid)
     {
         UserAccountController uac = new UserAccountController();
         string      ePassword     = uac.EncryptPassword(password);
         UserAccount userCheck     = db.UserAccounts.Where(ua => ua.UserName == username && ua.Password == ePassword).FirstOrDefault();
         if (userCheck != null)
         {
             Session["userId"]   = userCheck.UserId;
             Session["username"] = userCheck.UserName;
             Session["fullname"] = userCheck.FullName;
             Session["status"]   = userCheck.Status;
             return(RedirectToAction("Index", "Admin"));
         }
         return(View());
     }
     return(View());
 }