Exemplo n.º 1
0
        public virtual ActionResult Login(Login model)
        {
            model.NeedsToBeActive = false;
            var membro = TClient.Authenticate(model);

            if (membro != null)
            {
                FormsAuthentication.SetAuthCookie(membro.Login, false);
                HttpContext.User = new GenericPrincipal(new GenericIdentity(membro.Login), new string[] { });
                if (!string.IsNullOrWhiteSpace(model.ReturnUrl))
                {
                    return(Redirect(model.ReturnUrl));
                }
                TempData["Alerta"] = new Alert("success", "Bem-vindo" + " " + model.Username);

                return(RedirectToAction(MVC.Clientes.cliente_filmes()));
            }
            else
            {
                membro = TClient.FindByUsername(model.Username);
                if (membro != null)
                {
                    TempData["Alerta"] = new Alert("error", "Senha incorreta");
                }
                TempData["Alerta"] = new Alert("error", "Usuário não existe");
                return(View(model));
            }
        }
Exemplo n.º 2
0
        public virtual ActionResult Login(Login model)
        {
            model.SudDomain          = Subdomain.Backoffice;
            model.NeedsToBeActive    = false;
            model.NeedsToBeConfirmed = false;
            //model.RequiresCaptcha = TParameter.FindByEnum(Parameter.LoginWithCaptcha) != null
            //Colocar no ClientServer

            //aqui
            var membro = TClient.Authenticate(model);

            FormsAuthentication.SetAuthCookie(membro.Login, true);
            if (membro != null)
            {
                FormsAuthentication.SetAuthCookie(membro.Login, model.Remember);
                HttpContext.User = new GenericPrincipal(new GenericIdentity(membro.Login), new string[] { });

                if (!string.IsNullOrWhiteSpace(model.ReturnUrl))
                {
                    return(Redirect(model.ReturnUrl));
                }
                return(RedirectToAction(MVC.Clientes.Index()));
            }
            else
            {
                ViewBag.Alerta = new Alert("error", TClient.GetErrorLogin(model));
                return(View(model));
            }
        }
Exemplo n.º 3
0
        public virtual ActionResult Login(Login model)
        {
            model.SudDomain = Subdomain.Painel;
            var usuario = TClient.Authenticate(model);

            if (usuario != null)
            {
                FormsAuthentication.SetAuthCookie(model.Username, model.Remember);
                HttpContext.User = new GenericPrincipal(new GenericIdentity(model.Username), new string[] { });

                var idioma = "pt-br";
                Thread.CurrentThread.CurrentCulture   = CultureInfo.CreateSpecificCulture(idioma);
                Thread.CurrentThread.CurrentUICulture = new CultureInfo(idioma);
                var cookie = Request.Cookies["linguagem"];
                if (cookie == null)
                {
                    cookie = new HttpCookie("linguagem")
                    {
                        Value = idioma
                    }
                }
                ;
                if (cookie.Value != idioma)
                {
                    cookie.Value = idioma;
                }
                Response.Cookies.Add(cookie);

                if (!string.IsNullOrWhiteSpace(model.ReturnUrl))
                {
                    return(Redirect(model.ReturnUrl));
                }
                return(RedirectToAction(MVC.Home.Index()));
            }
            else
            {
                ViewBag.Alerta = new Alert("error", TClient.GetErrorLogin(model));
                return(View(model));
            }
        }