public void OnAuthorization(AuthorizationFilterContext context)
 {
     if (!CustomAuthorization.ValidarClaimUsuario(context.HttpContext, _claim.Type, _claim.Value))
     {
         context.Result = new ForbidResult();
     }
 }
 public static bool IfClaim(this RazorPage page, string claimName, string claimValue)
 {
     try
     {
         return(CustomAuthorization.ValidarClaimUsuario(page.Context, claimName, claimValue));
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         return(CustomAuthorization.ValidarClaimUsuario(page.Context, claimName, claimValue));
     }
 }
Exemple #3
0
        public void OnAuthorization(AuthorizationFilterContext context)
        {
            if (!context.HttpContext.User.Identity.IsAuthenticated)
            {
                context.Result = new RedirectToRouteResult(new RouteValueDictionary(new { area = "Identity", page = "/Account/Login", ReturnUrl = context.HttpContext.Request.Path.ToString() }));
                return;
            }

            if (!CustomAuthorization.ValidarClaimUsuario(context.HttpContext, _claim.Type, _claim.Value))
            {
                context.Result = new StatusCodeResult(403);
            }
        }
Exemple #4
0
 public static IHtmlContent IfClaimShow(this IHtmlContent page, HttpContext context, string claimName, string claimValue)
 {
     return(CustomAuthorization.ValidarClaimUsuario(context, claimName, claimValue) ? page : null);
 }
Exemple #5
0
 public static string IfClaimShow(this RazorPage page, string claimName, string claimValue)
 {
     return(CustomAuthorization.ValidarClaimUsuario(page.Context, claimName, claimValue) ? "" : "disabled");
 }
Exemple #6
0
 public static bool IfClaim(this RazorPage page, string claimName, string claimValue)
 {
     return(CustomAuthorization.ValidarClaimUsuario(page.Context, claimName, claimValue));
 }