MCPcopy Create free account
hub / github.com/coder/coder / permittedOrganizations

Function permittedOrganizations

site/src/api/queries/organizations.ts:302–320  ·  view source on GitHub ↗
(check: AuthorizationCheck)

Source from the content-addressed store, hash-verified

300 * check, and returns only those that pass.
301 */
302export const permittedOrganizations = (check: AuthorizationCheck) => {
303 return {
304 queryKey: ["organizations", "permitted", check],
305 queryFn: async (): Promise<Organization[]> => {
306 const orgs = await API.getOrganizations();
307 const checks = Object.fromEntries(
308 orgs.map((org) => [
309 org.id,
310 {
311 ...check,
312 object: { ...check.object, organization_id: org.id },
313 },
314 ]),
315 );
316 const permissions = await API.checkAuthorization({ checks });
317 return orgs.filter((org) => permissions[org.id]);
318 },
319 };
320};
321
322/**
323 * Fetch permissions for all provided organizations.

Callers 4

CreateUserFormFunction · 0.90
CreateTemplateFormFunction · 0.90
AgentCreateFormFunction · 0.90

Calls 2

checkAuthorizationMethod · 0.80
filterMethod · 0.80

Tested by

no test coverage detected