public async Task <bool> IsAllowedAsync(
            ClaimsPrincipal principal,
            string module,
            string type,
            string action)
        {
            if (await IsAllowedForEveryoneAsync(
                    module,
                    type,
                    action))
            {
                return(true);
            }

            var user = await _userManager.GetUserAsync(principal);

            if (user == null)
            {
                return(false);
            }

            if (await IsAllowedForRegisteredUsersAsync(
                    module,
                    type,
                    action))
            {
                return(true);
            }

            var roles = await _userManager.GetRolesAsync(user);

            foreach (var role in roles)
            {
                var allowed = await _permissionsService.AllowedAsync(module, type, action, role, true);

                if (allowed)
                {
                    return(true);
                }
            }

            return(false);
        }