fix: allows leader of challenge to create new challenge tasks even when not a participant of the challenge. fixes #7918

closes #7924
This commit is contained in:
Husman
2016-08-24 08:22:58 -07:00
committed by Blade Barringer
parent 5bcc2561ae
commit 2308e14d3e
2 changed files with 8 additions and 9 deletions

View File

@@ -120,7 +120,7 @@ api.createChallengeTasks = {
let challenge = await Challenge.findOne({_id: challengeId}).exec();
// If the challenge does not exist, or if it exists but user is not the leader -> throw error
if (!challenge || user.challenges.indexOf(challengeId) === -1) throw new NotFound(res.t('challengeNotFound'));
if (!challenge) throw new NotFound(res.t('challengeNotFound'));
if (challenge.leader !== user._id) throw new NotAuthorized(res.t('onlyChalLeaderEditTasks'));
let tasks = await _createTasks(req, res, user, challenge);