Exemplo n.º 1
0
 public ActionResult Login(LoginModel model)
 {
     if (ModelState.IsValid)
     {
         var f_user = new F_User();
         var result = f_user.Login_Test(model.UserName, model.Password);
         if (result)
         {
             var user        = f_user.getByUserName(model.UserName);
             var userSession = new UserLogin();
             userSession.UserName = user.UserName;
             userSession.UserID   = user.ID;
             userSession.GroupID  = user.GroupID;
             Session.Add(CommonConstants.USER_SESSION, userSession);
         }
         else
         {
         }
     }
     else
     {
         ModelState.AddModelError("", "Dang nhap khong dunng");
     }
     return(View("Index"));
 }
Exemplo n.º 2
0
        public ActionResult Login(User model)
        {
            var f_user = new F_User();
            var result = f_user.Login_Test(model.UserName, Encryptor.MD5Hash(model.Password));

            if (result)
            {
                var user        = f_user.Login(model.UserName, Encryptor.MD5Hash(model.Password));
                var userSession = new UserLogin();
                userSession.UserName = user.UserName;
                userSession.UserID   = user.ID;
                userSession.GroupID  = user.GroupID;
                Session.Add(CommonConstants.USER_SESSION, userSession);
                if (user.GroupID == "ADMIN")
                {
                    return(Redirect("/Admin"));
                }
                else
                {
                    return(RedirectToAction("Index", "Home"));
                }
            }
            else
            {
                ModelState.AddModelError("", "Đăng nhập không đúng");
            }
            return(RedirectToAction("Login", "Home"));
        }