Пример #1
0
        public IActionResult Index()
        {
            Usuario usuario = _loginUsuario.GetUsuario();

            if (usuario == null)
            {
                ViewBag.Layout = "_Layout";
                return(View());
            }
            else
            {
                return(RedirectToAction(nameof(Painel)));
            }
        }
Пример #2
0
        public void OnAuthorization(AuthorizationFilterContext context)
        {
            _loginUsuario = (LoginUsuario)context.HttpContext.RequestServices.GetService(typeof(LoginUsuario));
            Usuario cliente = _loginUsuario.GetUsuario();

            if (cliente == null)
            {
                context.Result = new ContentResult()
                {
                    Content = "Acesso negado."
                };
            }
        }