Skip to content

Commit

Permalink
Fixed error on get the statistics of an user
Browse files Browse the repository at this point in the history
  • Loading branch information
uo289689 committed Apr 26, 2024
1 parent 0f080d7 commit 0cec2c1
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions users/routes/user-routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -588,12 +588,14 @@ router.get('/statistics/:username', async (req,res) => {
}
});

const hasCommonGroup = userGroups.some(userGroup => {
return loggedUserGroups.some(loggedUserGroup => loggedUserGroup.groupName === userGroup.groupName);
});

if(!hasCommonGroup){
return res.status(403).json({ error: 'You are not allowed to see this user statistics' });
if (loggedUserGroups.length != 0 && userGroups != 0){
const hasCommonGroup = userGroups.some(userGroup => {
return loggedUserGroups.some(loggedUserGroup => loggedUserGroup.groupName === userGroup.groupName);
});

if(!hasCommonGroup){
return res.status(403).json({ error: 'You are not allowed to see this user statistics' });
}
}
}

Expand Down

0 comments on commit 0cec2c1

Please sign in to comment.