Skip to content

Commit

Permalink
Merge pull request #3738 from uselagoon/add-project-org-error-fix
Browse files Browse the repository at this point in the history
fix: return an error if organization doesnt exist on addproject
  • Loading branch information
tobybellwood authored Jun 13, 2024
2 parents a769bc7 + 271ab16 commit 64e2eda
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions services/api/src/resources/project/resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,18 @@ export const addProject = async (
await hasPermission('organization', 'addProject', {
organization: input.organization
});
// check the project quota before adding the project
const organization = await organizationHelpers(sqlClientPool).getOrganizationById(input.organization);
if (!organization) {
// org doesn't exist, unauth
throw new Error(
`Unauthorized: You don't have permission to "addProject" on "organization"`
);
}
// 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);
if (projects.length >= organization.quotaProject && organization.quotaProject != -1) {
throw new Error(
Expand Down

0 comments on commit 64e2eda

Please sign in to comment.