Example #1
0
        public ActionResult Login(AutenticacaoModel usuario)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    foreach (var cookieKey in Request.Cookies.AllKeys.Where(c => !c.Equals("__RequestVerificationToken")))
                    {
                        var deleteCookie = new HttpCookie(cookieKey);
                        deleteCookie.Expires = DateTime.Now;
                        Response.Cookies.Add(deleteCookie);
                    }

                    AutorizacaoProvider.Logar(usuario);

                    if (!string.IsNullOrWhiteSpace(usuario.Nome))
                    {
                        return(Json(new { url = usuario.Nome.Replace("$", "&") }));
                    }
                    else
                    {
                        return(Json(new { url = Url.Action(ConfigurationManager.AppSettings["Web:DefaultAction"], ConfigurationManager.AppSettings["Web:DefaultController"]) }));
                    }
                }

                return(View(usuario));
            }
            catch (Exception ex)
            {
                return(Json(new { alerta = ex.Message, titulo = "Oops! Problema ao realizar login..." }));
            }
        }
Example #2
0
        public ActionResult LoginComCaptcha(AutenticacaoModel usuario)
        {
            MvcCaptcha.ResetCaptcha("LoginCaptcha");
            ViewBag.IncluirCaptcha = Convert.ToBoolean(ConfigurationManager.AppSettings["AD:DMZ"]);

            try
            {
                if (ModelState.IsValid)
                {
                    AutorizacaoProvider.Logar(usuario);

                    if (!string.IsNullOrWhiteSpace(usuario.Nome))
                    {
                        return(Json(new { url = usuario.Nome.Replace("$", "&") }));
                    }
                    else
                    {
                        return(Json(new { url = Url.Action(ConfigurationManager.AppSettings["Web:DefaultAction"], ConfigurationManager.AppSettings["Web:DefaultController"]) }));
                    }
                }

                return(View("Login", usuario));
            }
            catch (Exception ex)
            {
                return(Json(new { alerta = ex.Message, titulo = "Oops! Problema ao realizar login..." }));
            }
        }
Example #3
0
        public ActionResult Login(AutenticacaoModel usuario)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    AutorizacaoProvider.Logar(usuario);
                    return(Json(new { url = Url.Action("Index", "Painel") }));
                }

                return(View(usuario));
            }
            catch (Exception ex)
            {
                return(Json(new { alerta = ex.Message, titulo = "Oops! Problema ao realizar login..." }));
            }
        }