Skip to main content
Glama
UserExtension.cs1.57 kB
using Api.DigitalPages.Interfaces.Connector; using Api.DigitalPages.Interfaces.Models; using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Api.DigitalPages.Interfaces.Extensions { public static class UserExtension { public static IBaseAuthorizationFilter AuthorizationFilterFrom (this IUser user, List<IEntityItem> entities, List<IProduct> products) { if (user.Roles.Any(p=> p.Type == RoleType.PlatformSuper || p.Type == RoleType.System || p.Type == RoleType.AdministratorGlobal)) { return null; } return new BaseAuthorizationFilter { Directories = new List<Guid> { user.ParentUid }, Projects = user.Projects?.Select(p => p.Uid)?.ToList(), Entities = entities?.Select(p => p.Uid)?.ToList(), Users = new List<Guid> { user.Uid }, OnlyToAnonymousUser = user.Roles?.Any(p => p.Type != RoleType.Anonymous) == false, Products = products?.Select(p => p.Uid)?.ToList() }; } } internal class BaseAuthorizationFilter : IBaseAuthorizationFilter { public List<Guid> Directories { get; set; } public List<Guid> Projects { get; set; } public List<Guid> Entities { get; set; } public List<Guid> Users { get; set; } public List<Guid> Products { get; set; } public bool OnlyToAnonymousUser { get; set; } } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/rkm097git/euconquisto-composer-mcp-poc'

If you have feedback or need assistance with the MCP directory API, please join our Discord server