public ActionResult Login() { SessionContext login = new SessionContext(); if (login.logado() == true) { return RedirectToAction("Index", "Home"); } return View(); }
public ActionResult Login(Usuario user) { UserApplication userApp = new UserApplication(this._contexto); var authenticatedUser = userApp.GetByUsernameAndPassword(user); SessionContext login = new SessionContext(); Usuario usuario = (from p in this._contexto.TabelaUsuarios where p.Username == user.Username select p).FirstOrDefault(); if ((authenticatedUser != null) & (login.logado() == false)) { context.SetAuthenticationToken(authenticatedUser.Name, false, authenticatedUser); return RedirectToAction("Index", "Home"); } ViewBag.Error = "Login inválido, tente novamente!"; return View(); }