-
Notifications
You must be signed in to change notification settings - Fork 52
[PROD RELEASE] - WM related updates #740
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: master
Are you sure you want to change the base?
Changes from 1 commit
c2311d9
b1202f4
26c4ad2
9c63f6b
644226a
0a4cdf9
220845b
a038462
940ef7b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,22 @@ function hasAdminRole(authUser) { | |
return false; | ||
} | ||
|
||
/** | ||
* Check if the user has admin role | ||
* @param {Object} authUser the user | ||
*/ | ||
function hasProjectManagerRole(authUser) { | ||
if (authUser && authUser.roles) { | ||
for (const role of authUser.roles) { | ||
if (role.toLowerCase() === constants.UserRoles.ProjectManager.toLowerCase()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider using |
||
return true; | ||
} | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
module.exports = { | ||
hasAdminRole, | ||
hasProjectManagerRole, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,7 +35,7 @@ const PhaseAdvancer = require("../phase-management/PhaseAdvancer"); | |
const { ChallengeDomain } = require("@topcoder-framework/domain-challenge"); | ||
const { QueryDomain } = require("@topcoder-framework/domain-acl"); | ||
|
||
const { hasAdminRole } = require("../common/role-helper"); | ||
const { hasAdminRole, hasProjectManagerRole } = require("../common/role-helper"); | ||
const { | ||
enrichChallengeForResponse, | ||
sanitizeRepeatedFieldsInUpdateRequest, | ||
|
@@ -152,6 +152,7 @@ async function searchChallenges(currentUser, criteria) { | |
]; | ||
|
||
const _hasAdminRole = hasAdminRole(currentUser); | ||
const _hasProjectManagerRole = hasProjectManagerRole(currentUser); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider checking if |
||
|
||
const includedTrackIds = _.isArray(criteria.trackIds) ? criteria.trackIds : []; | ||
const includedTypeIds = _.isArray(criteria.typeIds) ? criteria.typeIds : []; | ||
|
@@ -588,7 +589,7 @@ async function searchChallenges(currentUser, criteria) { | |
// FIXME: Tech Debt | ||
let excludeTasks = true; | ||
// if you're an admin or m2m, security rules wont be applied | ||
if (currentUser && (_hasAdminRole || _.get(currentUser, "isMachine", false))) { | ||
if (currentUser && (_hasAdminRole || _hasProjectManagerRole || _.get(currentUser, "isMachine", false))) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The variable |
||
excludeTasks = false; | ||
} | ||
|
||
|
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.
There is a typo in the variable name
canAccesChallenge
. It should becanAccessChallenge
to maintain consistency and readability.