fix edge case where res.respond would not work, misc comments
This commit is contained in:
@@ -146,6 +146,7 @@ api.getChallenge = {
|
||||
let challenge = await Challenge.findOne({_id: challengeId}).exec(); // TODO populate
|
||||
|
||||
// If the challenge does not exist, or if it exists but user is not a member, not the leader and not an admin -> throw error
|
||||
// TODO support challenges in groups I'm a member of
|
||||
if (!challenge || (user.challenges.indexOf(challengeId) === -1 && challenge.leader !== user._id && !user.contributor.admin)) { // eslint-disable-line no-extra-parens
|
||||
throw new NotFound(res.t('challengeNotFound'));
|
||||
}
|
||||
|
||||
@@ -100,13 +100,13 @@ api.getGroups = {
|
||||
type: 'guild',
|
||||
privacy: 'private',
|
||||
_id: {$in: user.guilds},
|
||||
}).select(groupFields).sort(sort).exec()); // TODO isMember
|
||||
}).select(groupFields).sort(sort).exec());
|
||||
break;
|
||||
case 'publicGuilds':
|
||||
queries.push(Group.find({
|
||||
type: 'guild',
|
||||
privacy: 'public',
|
||||
}).select(groupFields).sort(sort).exec()); // TODO use lean? isMember
|
||||
}).select(groupFields).sort(sort).exec()); // TODO use lean?
|
||||
break;
|
||||
case 'tavern':
|
||||
queries.push(Group.getGroup(user, 'habitrpg', groupFields));
|
||||
|
||||
Reference in New Issue
Block a user