예제 #1
0
 public ActionResult Login(LoginUser u, bool captchaValid)
 {
     if (ModelState.IsValid)
     {
         using (LogInService ls = new LogInService())
         {
             User user = ls.Login(u.Username, u.Password);
             if (user != null)
             {
                 String userType = ls.GetUserType(user.UserId);
                 int    id       = user.UserId;
                 Session["Id"]       = id;
                 Session["Username"] = user.Username;
                 Session["UserType"] = userType;
                 return(RedirectToAction("Index", "Home"));
             }
             else
             {
                 ViewBag.LoginError = "Invalid username or password";
                 return(View(u));
             }
         }
     }
     return(View(u));
 }
예제 #2
0
        public ActionResult Login(string UserName, string Password)
        {
            User user = new User
            {
                UserName = UserName,
                Password = Password
            };

            User userNew = lis.Login(user);

            Session["user_id"]    = userNew.Id;
            Session["userName"]   = userNew.UserName;
            Session["session_id"] = userNew.Session.Session_id;

            if (Session["user_id"] != null)
            {
                List <Entertainment> entertainments;
                entertainments = eS.GetEntertainments();
                return(View("Index", entertainments));
            }
            else
            {
                ViewBag.Message = "You need to log in";
                return(View("LogIn"));
            }
        }