Esempio n. 1
0
        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"));
            }
        }
Esempio n. 2
0
        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"));
        }
Esempio n. 3
0
        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"));
        }
Esempio n. 4
0
        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"));
        }
Esempio n. 5
0
    /// <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);
        }
    }
Esempio n. 6
0
        public ActionResult LogOff()
        {
            FormsAuthenticationUtil.SignOut();

            return(RedirectToAction("Index", "Login"));
        }
Esempio n. 7
0
 private void CriaTicket(Empresa empresa)
 {
     FormsAuthenticationUtil.RedirectFromLoginPage(empresa.NomeFantasia, string.Empty, RememberMe.Checked);
 }
Esempio n. 8
0
        public ActionResult LogOff()
        {
            FormsAuthenticationUtil.SignOut();

            return(RedirectToAction("Cadastro", "Cliente"));
        }
Esempio n. 9
0
 protected void Application_AuthenticateRequest(object sender, EventArgs e)
 {
     FormsAuthenticationUtil.AttachRolesToUser();
 }
Esempio n. 10
0
 private void CriaTicket(Model.Empresa empresa)
 {
     FormsAuthenticationUtil.RedirectFromLoginPage(empresa.NomeFantasia, string.Empty, false);
 }