improve access control for challenges

This commit is contained in:
Matteo Pagliazzi
2016-01-24 12:52:59 +01:00
parent 198d2e6ab5
commit 59f5a80af7
3 changed files with 25 additions and 26 deletions

View File

@@ -192,7 +192,7 @@ api.getChallenge = {
let challenge = await Challenge.findById(challengeId).exec();
if (!challenge) throw new NotFound(res.t('challengeNotFound'));
let group = await Group.getGroup({user, groupId: challenge.groupId, fields: '_id type privacy'});
let group = await Group.getGroup({user, groupId: challenge.groupId, fields: '_id type privacy', optionalMembership: true});
if (!group || !challenge.canView(user, group)) throw new NotFound(res.t('challengeNotFound'));
res.respond(200, challenge);