コード例 #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();
            }
        }
コード例 #2
0
 public static IHtmlContent ifShow(this IHtmlContent page, HttpContext httpContext, string claimName, string claimValue)
 {
     return(CustomClains.ValidarAcesso(httpContext, claimName, claimValue) ? page : null);
 }
コード例 #3
0
 public static string ifClaimShow(this RazorPage page, string claimName, string claimValue)
 {
     return(CustomClains.ValidarAcesso(page.Context, claimName, claimValue) ? "" : "disabled");
 }
コード例 #4
0
 public static bool IfClaim(this RazorPage page, string claimName, string claimValue)
 {
     return(CustomClains.ValidarAcesso(page.Context, claimName, claimValue));
 }