예제 #1
0
        public void OnAuthorization(AuthorizationFilterContext context)
        {
            //Metodo usado para customizar para uma pagina especifica quando o usuario não tem acesso

            if (!context.HttpContext.User.Identity.IsAuthenticated)
            {
                context.Result = new RedirectToRouteResult(new RouteValueDictionary(values: new { area = "Identity", page = "/Account/Login", ReturnUrl = context.HttpContext.Request.Path.ToString() }));
            }
            if (!CustomClains.ValidarAcesso(context.HttpContext, claimName: _claim.Type, claimValue: _claim.Value))
            {
                context.Result = new ForbidResult();
            }
        }
 public static IHtmlContent ifShow(this IHtmlContent page, HttpContext httpContext, string claimName, string claimValue)
 {
     return(CustomClains.ValidarAcesso(httpContext, claimName, claimValue) ? page : null);
 }
 public static string ifClaimShow(this RazorPage page, string claimName, string claimValue)
 {
     return(CustomClains.ValidarAcesso(page.Context, claimName, claimValue) ? "" : "disabled");
 }
 public static bool IfClaim(this RazorPage page, string claimName, string claimValue)
 {
     return(CustomClains.ValidarAcesso(page.Context, claimName, claimValue));
 }