public override async Task <MenuGrantResultEnum> CheckAsync(MenuGrantRuntimeCheckerContent context)
        {
            var userId = context.Principal?.FindFirst(AbpClaimTypes.UserId)?.Value;
            var result = await MenuGrantChecker.CheckAsync(context.Menu.Id, "U", userId);

            return(result.IsGranted ? MenuGrantResultEnum.Granted : MenuGrantResultEnum.Undefined);
        }
Esempio n. 2
0
        public virtual async Task <MenuGrantInfo> CheckAsync(Guid menuId, string providerName, string providerKey)
        {
            if (providerName != Name)
            {
                return(MenuGrantInfo.NonGranted);
            }

            return(new MenuGrantInfo(
                       (await MenuGrantChecker.CheckAsync(menuId, providerName, providerKey)).IsGranted,
                       providerKey
                       ));
        }
        public override async Task <MenuGrantResultEnum> CheckAsync(MenuGrantRuntimeCheckerContent context)
        {
            var roles = context.Principal?.FindAll(AbpClaimTypes.Role).Select(c => c.Value).ToArray();

            if (roles == null || !roles.Any())
            {
                return(MenuGrantResultEnum.Undefined);
            }

            foreach (var role in roles)
            {
                var result = await MenuGrantChecker.CheckAsync(context.Menu.Id, "R", role);

                if (result.IsGranted)
                {
                    return(MenuGrantResultEnum.Granted);
                }
            }

            return(MenuGrantResultEnum.Undefined);
        }