public ActionResult Login(User user) { try { SecurityDAOService sservice = new SecurityDAOService(); bool results = sservice.Authenticate(user); if (results) { user = sservice.LoadUser(user); ScoreDAOService scoreDO = new ScoreDAOService(); user.Stats = scoreDO.GetUserScores(user).Take(5).ToList(); Session["User"] = user; Tuple <User, List <PlayerStat> > tuple = new Tuple <User, List <PlayerStat> >(user, ReturnGlobalStats()); //pass the user and the global stats logger.Info("Success at LoginController Login() with login success."); return(View("~/Views/Profile/Profile.cshtml", tuple)); //return View("LoginSuccess", model); } else { logger.Info("Success at LoginController Login() with login failure."); return(View("LoginFailed")); } } catch { logger.Error("Failure at LoginController Login()."); return(View("Error")); } }
public void OnAuthorization(AuthorizationContext filterContext) { SecurityDAOService securityService = new SecurityDAOService(); User user = (User)filterContext.HttpContext.Session["User"]; bool success = securityService.Authenticate(user); if (!success) { filterContext.Result = new RedirectResult("/login"); } }