-
Notifications
You must be signed in to change notification settings - Fork 55
PM- 1612 Copilot Applications should be visible to all with selective data #854
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
base: develop
Are you sure you want to change the base?
Conversation
module.exports = [ | ||
permissions('copilotApplications.view'), | ||
(req, res, next) => { | ||
const canAccessAllApplications = util.hasRoles(req, ADMIN_ROLES) || util.hasProjectManagerRole(req); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider checking if req.params.id
is a valid integer before using _.parseInt
. This can prevent potential errors if the parameter is not a number.
const enrichedApplications = copilotApplications.map(application => { | ||
const m = members.find(m => m.userId === application.userId); | ||
const enrichedApplications = copilotApplications.map((application) => { | ||
const m = members.find(member => member.userId === application.userId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider renaming the variable m
to something more descriptive, such as member
, to improve code readability.
@@ -86,13 +79,21 @@ module.exports = [ | |||
return enriched; | |||
}); | |||
|
|||
const response = canAccessAllApplications |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider renaming canAccessAllApplications
to something more descriptive like isAdminOrPM
to clarify the condition being checked.
@@ -86,13 +79,21 @@ module.exports = [ | |||
return enriched; | |||
}); | |||
|
|||
const response = canAccessAllApplications | |||
? enrichedApplications |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ternary operation here is clear, but consider adding a brief explanation in the documentation or codebase about the logic behind canAccessAllApplications
to improve maintainability.
status: app.status, | ||
createdAt: app.createdAt, | ||
})); | ||
|
||
req.log.debug(`Enriched Applications ${JSON.stringify(enrichedApplications)}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The debug log statement Enriched Applications
should be updated to reflect the new variable response
being logged instead of enrichedApplications
.
The API should not restrict users, instead we're adding a filter to the response later.
Admins and PMs can view the entire response and the rest of the users can view only handles, status and applied date.