From 64b5edf65a8dd39f4cbe541b9850fb0daea897b9 Mon Sep 17 00:00:00 2001 From: Hentry Martin Date: Tue, 6 May 2025 00:42:57 +0200 Subject: [PATCH] fix: allow pm to access all applications --- .circleci/config.yml | 2 +- src/permissions/copilotApplications.view.js | 24 ++++++++------------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 1acd4a4c..b47ae64b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -149,7 +149,7 @@ workflows: context : org-global filters: branches: - only: ['develop', 'migration-setup'] + only: ['develop', 'migration-setup', 'pm-855_1'] - deployProd: context : org-global filters: diff --git a/src/permissions/copilotApplications.view.js b/src/permissions/copilotApplications.view.js index 9b0c917b..b333cc3c 100644 --- a/src/permissions/copilotApplications.view.js +++ b/src/permissions/copilotApplications.view.js @@ -21,23 +21,17 @@ module.exports = freq => new Promise((resolve, reject) => { const req = freq; req.context = req.context || {}; req.context.currentOpportunity = opportunity; - const projectId = opportunity.projectId; const isProjectManager = util.hasProjectManagerRole(req); - return models.ProjectMember.getActiveProjectMembers(projectId) - .then((members) => { - - return models.CopilotApplication.findOne({ - where: { - opportunityId: opportunityId, - userId: currentUserId, - }, - }).then((copilotApplication) => { - const isPartOfProject = isProjectManager && members.find(member => member.userId === currentUserId); - // check if auth user has access to this project - const hasAccess = util.hasAdminRole(req) || isPartOfProject || !!copilotApplication; - return Promise.resolve(hasAccess); - }) + return models.CopilotApplication.findOne({ + where: { + opportunityId: opportunityId, + userId: currentUserId, + }, + }).then((copilotApplication) => { + // check if auth user has access to this project + const hasAccess = util.hasAdminRole(req) || isProjectManager || !!copilotApplication; + return Promise.resolve(hasAccess); }) }) .then((hasAccess) => {