Skip to content

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

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

himaniraghav3
Copy link
Collaborator

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.

module.exports = [
permissions('copilotApplications.view'),
(req, res, next) => {
const canAccessAllApplications = util.hasRoles(req, ADMIN_ROLES) || util.hasProjectManagerRole(req);

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

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

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

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

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants