public ActionResult Index() { Usuario usua = appServiceUsuario.LoginUsuario("*******", "leleo_0"); var models = ListaUsuario; return(View(models)); }
public ActionResult Login(LoginViewModel login) { if (ModelState.IsValid) { var usu = appServiceUsuario.LoginUsuario(login.Senha, login.Nome); if (usu == null) { Warning("Login e/ou senha inválido", true); return(View(login)); } else { if (!usu.Ativo) { Warning("Este usuário está bloqueado", true); return(View(login)); } else { var authTicket = new FormsAuthenticationTicket( 1, usu.Nome, DateTime.Now, DateTime.Now.AddMinutes(30), false, usu.Permissao, FormsAuthentication.FormsCookiePath ); var authCrypt = FormsAuthentication.Encrypt(authTicket); var authCookie = new HttpCookie(FormsAuthentication.FormsCookieName, authCrypt); HttpContext.Response.Cookies.Add(authCookie); return(RedirectToAction("Index", "Home")); } } } else { return(View(login)); } }