Пример #1
0
        public void OnAuthorization(AuthorizationFilterContext context)
        {
            var user = context.HttpContext.User;

            if (user.Identity.IsAuthenticated == false)
            {
                //REDIRECCION DINAMICA
                ToolkitService.GuardarAcctionController(context);
                //LOGIN
                context.Result = ToolkitService.GetRedirectToRoute("Identity", "Login");
            }
        }
Пример #2
0
        public void OnAuthorization(AuthorizationFilterContext context)
        {
            var user = context.HttpContext.User;

            if (user.Identity.IsAuthenticated == false)
            {
                //REDIRECCION DINAMICA
                ToolkitService.GuardarAcctionController(context);

                //LOGIN
                //Redirigo al Login
                context.Result = ToolkitService.GetRedirectToRoute("Identity", "Login");
            }
            else
            {
                //SOLO LOS ADMINISTRADORES PUEDEN ENTRAR
                if (user.IsInRole("ADMIN") == false)
                {
                    //context.Result = this.GetRedirectToRoute("Identity", "AccesoDenegado");
                    context.Result = ToolkitService.GetRedirectToRoute("Identity", "AccesoDenegado");
                }
            }
        }