Skip to content
Closed
Changes from all 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
4 changes: 0 additions & 4 deletions src/services/ChallengeService.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,10 +306,6 @@ async function searchChallenges (currentUser, criteria) {

// Filter all groups from the criteria to make sure the user can access those
if (!_.isUndefined(criteria.group) || !_.isUndefined(criteria.groups)) {
// check group access
if (_.isUndefined(currentUser)) {
throw new errors.BadRequestError('Authentication is required to filter challenges based on groups')
Copy link
Contributor

Choose a reason for hiding this comment

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

The fix is clearly wrong.

Currently, if the currentUser is not set, we're throwing an error.
By removing that code, you are making the rest of the code prone to cannot get property "<prop>" of undefined errors.

Also, there's currently no check on whether a group is public or not which means, even if you bypass the above errors, you will still get wrong results back as the accessibleGroups, which is used to determine if the user has access to the requested groups, will be empty (since the user is not authenticated).

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks @ThomasKranitsas , I'll remove this from Bug Bash.

}
if (!currentUser.isMachine && !helper.hasAdminRole(currentUser)) {
if (accessibleGroups.includes(criteria.group)) {
groupsToFilter.push(criteria.group)
Expand Down