Allow leaving a challenge without having access to the challenge (e.g. after leaving a party or guild)

This commit is contained in:
Céline O'Neil
2017-04-26 13:52:27 -07:00
committed by savoie
parent 78816dd4cb
commit fb80dd7c57
2 changed files with 10 additions and 12 deletions

View File

@@ -190,9 +190,6 @@ api.leaveChallenge = {
let challenge = await Challenge.findOne({ _id: req.params.challengeId }).exec();
if (!challenge) throw new NotFound(res.t('challengeNotFound'));
let group = await Group.getGroup({user, groupId: challenge.group, fields: '_id type privacy'});
if (!group || !challenge.canView(user, group)) throw new NotFound(res.t('challengeNotFound'));
if (!challenge.isMember(user)) throw new NotAuthorized(res.t('challengeMemberNotFound'));
// Unlink challenge's tasks from user's tasks and save the challenge