Skip to content

fix(PM-1067): allow project managers to view applications of opportunity not b… #807

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 14, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ workflows:
context : org-global
filters:
branches:
only: ['develop', 'migration-setup']
only: ['develop', 'migration-setup', 'pm-1067_1']
- deployProd:
context : org-global
filters:
Expand Down
24 changes: 9 additions & 15 deletions src/permissions/copilotApplications.view.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable projectId is declared but not used in the updated code. Consider removing it to clean up the code.


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);
})
})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hasAccess logic has changed. Ensure that the removal of isPartOfProject does not affect the intended access control logic. Verify that project managers should have access regardless of project membership.

.then((hasAccess) => {
Expand Down