public ActionResult Entrar(Usuario obj) { if (!Validacoes.ValidarCampos(obj.Email) || !Validacoes.ValidarCampos(obj.Senha)) { ViewBag.ErroMsg = "Campos vazios não são permitidos!"; return(View("Index")); } var usuarioLogado = new UsuarioDAO().Login(obj); if (usuarioLogado == null) { return(RedirectToAction("Index", "Login")); } var userData = new JavaScriptSerializer().Serialize(usuarioLogado); FormsAuthenticationUtil.SetCustomAuthCookie(usuarioLogado.Email, userData, false); if (usuarioLogado.PerfilUsuario == Perfil.Estudante) { return(RedirectToAction("TelaInicial", "Estudante")); } else { return(RedirectToAction("TelaInicial", "Professor")); } }
public ActionResult Entrar(Usuario obj) { var usuarioLogado = new UsuarioDAO().Logar(obj); if (usuarioLogado == null) { return(View("Index")); } var userData = new JavaScriptSerializer().Serialize(usuarioLogado); FormsAuthenticationUtil.SetCustomAuthCookie(usuarioLogado.Email, userData, false); return(RedirectToAction("Index", "PerfilTera")); }
public ActionResult Entrar(Jogador obj) { var jogadorLogado = new JogadorDAO().Logar(obj); if (jogadorLogado == null) { ViewBag.MsgErro = "Email ou senha invalido"; return(View("IndexLogin")); } var userData = new JavaScriptSerializer().Serialize(jogadorLogado); FormsAuthenticationUtil.SetCustomAuthCookie(jogadorLogado.Email, userData, false); return(RedirectToAction("PaginaInicial", "PagInicio")); }
public ActionResult Entrar(Confeiteira obj) { var usuarioLogado = new UsuarioDAO().Logar(obj); if (usuarioLogado == null) { ViewBag.ErrorMsg = @"Login ou senha inválido!"; return(View("Index")); } var userData = new JavaScriptSerializer().Serialize(new Usuario() { Id = usuarioLogado.Id, Nome = usuarioLogado.Nome, Login = usuarioLogado.Email }); FormsAuthenticationUtil.SetCustomAuthCookie(usuarioLogado.Login, userData, false); return(RedirectToAction("Index", "Pedido")); }
/// <summary> /// Logs In a User to the web site and redirects to the desired page. /// </summary> /// <param name="user"></param> /// <param name="userName"></param> /// <param name="rememberMe"></param> protected void LoginUser(User user, String userName, bool rememberMe) { if (user == null) //Login Failed { //SessionCache.AttemptedUserName = userName; SessionCache.FailedLoginAttemptCount = SessionCache.FailedLoginAttemptCount + 1; WebUtil.ShowMessageBox(divMessage, "Login Failed. Your login was unsuccessful. Check your User Name, Password and try again.", true); } else { //if (String.Compare(user.IsActive, "A", false) != 0) //{ // String message = @"Your login information is valid, however your account has been disabled."; // WebUtil.ShowMessageBox(divMessage, message, true); // SessionCache.FailedLoginAttemptCount = SessionCache.FailedLoginAttemptCount + 1; // return; //} SessionCache.CurrentUser = user; ///After Successfull Login Redirect to the Requested Page //System.Web.Security.FormsAuthentication.RedirectFromLoginPage(user.UserLogInName, rememberMe); FormsAuthenticationUtil.RedirectFromLoginPage(user.UserNameWeb, "Administrator", rememberMe); } }
public ActionResult LogOff() { FormsAuthenticationUtil.SignOut(); return(RedirectToAction("Index", "Login")); }
private void CriaTicket(Empresa empresa) { FormsAuthenticationUtil.RedirectFromLoginPage(empresa.NomeFantasia, string.Empty, RememberMe.Checked); }
public ActionResult LogOff() { FormsAuthenticationUtil.SignOut(); return(RedirectToAction("Cadastro", "Cliente")); }
protected void Application_AuthenticateRequest(object sender, EventArgs e) { FormsAuthenticationUtil.AttachRolesToUser(); }
private void CriaTicket(Model.Empresa empresa) { FormsAuthenticationUtil.RedirectFromLoginPage(empresa.NomeFantasia, string.Empty, false); }