diff --git a/services/api/src/resources/group/resolvers.ts b/services/api/src/resources/group/resolvers.ts index c9f06bb188..c93cc4f24a 100644 --- a/services/api/src/resources/group/resolvers.ts +++ b/services/api/src/resources/group/resolvers.ts @@ -190,10 +190,10 @@ export const getGroupsByProjectId: ResolverFn = async ( _input, { hasPermission, sqlClientPool, models, keycloakGrant, keycloakGroups, keycloakUsersGroups, adminScopes } ) => { + const projectGroups = await models.GroupModel.loadGroupsByProjectIdFromGroups(pid, keycloakGroups); // use the admin scope check instead of `hasPermission` for speed if (adminScopes.groupViewAll) { try { - const projectGroups = await models.GroupModel.loadGroupsByProjectIdFromGroups(pid, keycloakGroups); return projectGroups; } catch (err) { if (!keycloakGrant) { @@ -202,7 +202,6 @@ export const getGroupsByProjectId: ResolverFn = async ( } } } else { - const projectGroups = await models.GroupModel.loadGroupsByProjectIdFromGroups(pid, keycloakGroups); const user = await models.UserModel.loadUserById( keycloakGrant.access_token.content.sub ); @@ -237,7 +236,14 @@ export const getGroupsByProjectId: ResolverFn = async ( } } } - const userProjectGroups = R.intersection(projectGroups, userGroups); + let userProjectGroups = [] + for (const pg of projectGroups) { + for (const ug of userGroups) { + if (pg.id == ug.id) { + userProjectGroups.push(pg) + } + } + } return userProjectGroups; } @@ -262,7 +268,6 @@ export const getGroupsByUserId: ResolverFn = async ( } } const currentUserGroups = keycloakUsersGroups; - // const bothUserGroups = R.intersection(queryUserGroups, currentUserGroups); return currentUserGroups; }; diff --git a/services/api/src/resources/organization/resolvers.ts b/services/api/src/resources/organization/resolvers.ts index 10259d662c..20920c45c5 100644 --- a/services/api/src/resources/organization/resolvers.ts +++ b/services/api/src/resources/organization/resolvers.ts @@ -551,7 +551,14 @@ export const getGroupsByOrganizationsProject: ResolverFn = async ( } } } - const userProjectGroups = R.intersection(orgProjectGroups, userGroups); + let userProjectGroups = [] + for (const pg of orgProjectGroups) { + for (const ug of userGroups) { + if (pg.id == ug.id) { + userProjectGroups.push(pg) + } + } + } return userProjectGroups; };