Skip to content

Commit

Permalink
Merge branch 'develop_samuel' into develop-deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
uo289689 committed Apr 26, 2024
2 parents a409b17 + 0cec2c1 commit 620cb67
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 620cb67

Please sign in to comment.