From f35cd2d6a6914963e715292bcdcce9463539a8e2 Mon Sep 17 00:00:00 2001 From: Daniel Hougaard Date: Mon, 28 Apr 2025 05:20:56 +0400 Subject: [PATCH] Update project-service.ts --- .../src/services/project/project-service.ts | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/backend/src/services/project/project-service.ts b/backend/src/services/project/project-service.ts index 7e0d3b897..73a439055 100644 --- a/backend/src/services/project/project-service.ts +++ b/backend/src/services/project/project-service.ts @@ -1559,6 +1559,17 @@ export const projectServiceFactory = ({ } if (integration === WorkflowIntegration.SLACK) { + const { permission } = await permissionService.getProjectPermission({ + actor, + actorId, + projectId, + actorAuthMethod, + actorOrgId, + actionProjectType: ActionProjectType.Any + }); + + ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Edit, ProjectPermissionSub.Settings); + const sanitizedAccessRequestChannels = validateSlackChannelsField.parse(accessRequestChannels); const sanitizedSecretRequestChannels = validateSlackChannelsField.parse(secretRequestChannels); @@ -1576,17 +1587,6 @@ export const projectServiceFactory = ({ }); } - const { permission } = await permissionService.getProjectPermission({ - actor, - actorId, - projectId, - actorAuthMethod, - actorOrgId, - actionProjectType: ActionProjectType.Any - }); - - ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Edit, ProjectPermissionSub.Settings); - if (slackIntegration.orgId !== project.orgId) { throw new ForbiddenRequestError({ message: "Selected slack integration is not in the same organization" @@ -1637,6 +1637,17 @@ export const projectServiceFactory = ({ } as const; } if (integration === WorkflowIntegration.MICROSOFT_TEAMS) { + const { permission } = await permissionService.getProjectPermission({ + actor, + actorId, + projectId, + actorAuthMethod, + actorOrgId, + actionProjectType: ActionProjectType.Any + }); + + ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Edit, ProjectPermissionSub.Settings); + if (isAccessRequestNotificationEnabled && !accessRequestChannels) { throw new BadRequestError({ message: "Access request channels are required when access request notifications are enabled" @@ -1676,17 +1687,6 @@ export const projectServiceFactory = ({ }); } - const { permission } = await permissionService.getProjectPermission({ - actor, - actorId, - projectId, - actorAuthMethod, - actorOrgId, - actionProjectType: ActionProjectType.Any - }); - - ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Edit, ProjectPermissionSub.Settings); - if (microsoftTeamsIntegration.orgId !== project.orgId) { throw new ForbiddenRequestError({ message: "Selected Microsoft Teams integration is not in the same organization"