Added initial get challenge task by id

This commit is contained in:
Keith Holliday
2016-03-08 12:42:05 -06:00
parent b5e1cd33e2
commit 22e64bb88e
2 changed files with 67 additions and 1 deletions

View File

@@ -257,7 +257,7 @@ api.getTask = {
if (!task) {
throw new NotFound(res.t('taskNotFound'));
} else if (!task.userId) { // If the task belongs to a challenge make sure the user has rights
let challenge = await Challenge.find().selec({_id: task.challenge.id}).select('leader').exec();
let challenge = await Challenge.find({_id: task.challenge.id}).select('leader').exec();
if (!challenge || (user.challenges.indexOf(task.challenge.id) === -1 && challenge.leader !== user._id && !user.contributor.admin)) { // eslint-disable-line no-extra-parens
throw new NotFound(res.t('taskNotFound'));
}