예제 #1
0
        public Task <ICollection <AdminModule> > ExecuteAsync(GetPermittedAdminModulesQuery query, IExecutionContext executionContext)
        {
            var userContext = executionContext.UserContext;

            if (userContext == null || !userContext.IsCofoundryUser())
            {
                return(Task.FromResult <ICollection <AdminModule> >(new AdminModule[0]));
            }

            var modules = _moduleRegistrations
                          .SelectMany(r => r.GetModules())
                          .Where(r => _permissionValidationService.HasPermission(r.RestrictedToPermission, executionContext.UserContext))
                          .SetStandardOrdering()
                          .ToList();

            return(Task.FromResult <ICollection <AdminModule> >(modules));
        }
예제 #2
0
        public IEnumerable <AdminModule> Execute(GetPermittedAdminModulesQuery query, IExecutionContext executionContext)
        {
            var userContext = executionContext.UserContext;

            if (userContext == null || !userContext.IsCofoundryUser())
            {
                return(Enumerable.Empty <AdminModule>());
            }

            var modules = _moduleRegistrations
                          .SelectMany(r => r.GetModules())
                          .Where(r => _permissionValidationService.HasPermission(r.RestrictedToPermission, executionContext.UserContext))
                          .SetStandardOrdering()
                          .ToList();

            return(modules);
        }