Esempio n. 1
0
        public ActionResult Login(LoginViewModel loginview)
        {
            var user = (from u in tmdt.THANHVIENs where u.TENDANGNHAP == loginview.UserName select u).SingleOrDefault();
            string password = login.encryptSHA(loginview.Password);  // Encode password

            if (password == user.MATKHAU)
            {
                SessionHelper.SetUserSession(loginview.UserName);
                return RedirectToAction("Index", "Home");
            }
            ModelState.AddModelError("", "Email hoặc mật khẩu không đúng");
            return View();
        }
 public ActionResult Login()
 {
     LoginViewModel loginview = new LoginViewModel();
     if (Request.Cookies["UserName"] != null && Request.Cookies["Password"] != null)
     {
         loginview.UserName = Request.Cookies["UserName"].Value;
         loginview.Password = Request.Cookies["Password"].Value;
     }
     return View(loginview);
 }