public ActionResult Login(Models.User user)
 {
     if (ModelState.IsValid)
     {
         if (user.CheckLogon())//notice parameters removed)
         {
             FormsAuthentication.SetAuthCookie(user.UserName, user.RememberMe);
             return(RedirectToAction("Index", "Home"));
         }
         else
         {
             ModelState.AddModelError("", "Login data is incorrect!");
         }
     }
     return(View(user));
 }
Esempio n. 2
0
 public ActionResult Login(Models.User user)
 {
     if (ModelState.IsValid)
     {
         if (user.CheckLogon(user.email, user.password))
         {
             FormsAuthentication.SetAuthCookie(user.email, true);
             //Get the ID of the user
             int userId = user.GetUserId(user.email);
             int admin  = user.GetUserRole(user.email);
             FormsAuthentication.SetAuthCookie(userId.ToString(), true);
             Session["userID"] = userId;
             Session["email"]  = user.email;
             Session["admin"]  = admin;
             return(RedirectToAction("Index", "Home"));
         }
         else
         {
             ModelState.AddModelError("", "Login details were incorrect");
         }
     }
     return(View(user));
 }