diff --git a/services/api/src/resources/group/resolvers.ts b/services/api/src/resources/group/resolvers.ts index 9b7765e60b..e393d9e0b9 100644 --- a/services/api/src/resources/group/resolvers.ts +++ b/services/api/src/resources/group/resolvers.ts @@ -379,8 +379,16 @@ export const addGroup: ResolverFn = async ( }); await models.GroupModel.addProjectToGroup(null, group); - // if the user is not an admin, or an organization add, then add the user as an owner to the group - if (!adminScopes.projectViewAll && !input.organization && keycloakGrant) { + // if the user is not an admin, then add the user as an owner to the group + let userAlreadyHasAccess = false; + if (adminScopes.projectViewAll) { + userAlreadyHasAccess = true + } + // if the group is created without the addOrgOwner boolean set to true, then do not add the user to the group as its owner + if (!input.addOrgOwner) { + userAlreadyHasAccess = true + } + if (!userAlreadyHasAccess && keycloakGrant) { const user = await models.UserModel.loadUserById( keycloakGrant.access_token.content.sub ); diff --git a/services/api/src/resources/project/resolvers.ts b/services/api/src/resources/project/resolvers.ts index 1806354238..fbd8185c9a 100644 --- a/services/api/src/resources/project/resolvers.ts +++ b/services/api/src/resources/project/resolvers.ts @@ -293,7 +293,10 @@ export const addProject = async ( await hasPermission('organization', 'addProject', { organization: input.organization }); - userAlreadyHasAccess = true + // if the project is created without the addOrgOwner boolean set to true, then do not add the user to the project as its owner + if (!input.addOrgOwner) { + userAlreadyHasAccess = true + } // check the project quota before adding the project const organization = await organizationHelpers(sqlClientPool).getOrganizationById(input.organization); const projects = await organizationHelpers(sqlClientPool).getProjectsByOrganizationId(input.organization); diff --git a/services/api/src/typeDefs.js b/services/api/src/typeDefs.js index 36a5c5c80d..633b887e51 100644 --- a/services/api/src/typeDefs.js +++ b/services/api/src/typeDefs.js @@ -1491,6 +1491,7 @@ const typeDefs = gql` developmentBuildPriority: Int deploymentsDisabled: Int organization: Int + addOrgOwner: Boolean buildImage: String sharedBaasBucket: Boolean } @@ -2175,6 +2176,7 @@ const typeDefs = gql` name: String! parentGroup: GroupInput organization: Int + addOrgOwner: Boolean } input UpdateGroupPatchInput {