コード例 #1
0
        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            if (output == null)
            {
                throw new ArgumentNullException(nameof(output));
            }

            var possuiAcesso = CustomAuthorization.ValidarClaimUsuario(_httpContextAccessor.HttpContext, IdentityClaimName, IdentityClaimValue);

            if (possuiAcesso)
            {
                return;
            }

            output.SuppressOutput();
        }
コード例 #2
0
        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            if (output == null)
            {
                throw new ArgumentNullException(nameof(output));
            }

            var possuiAcesso = CustomAuthorization.ValidarClaimUsuario(_httpContextAccessor.HttpContext, IdentityClaimName, IdentityClaimValue);

            if (possuiAcesso)
            {
                return;
            }

            output.Attributes.RemoveAll("href");
            output.Attributes.Add(new TagHelperAttribute("style", "cursor: not-allowed"));
            output.Attributes.Add(new TagHelperAttribute("title", "Você não tem permissão"));
        }