Fix /db/trial.request to handle when there is no req.user

This commit is contained in:
Scott Erickson 2016-05-03 14:53:54 -07:00
parent 98a5644226
commit 3ea562780d

View file

@ -43,7 +43,7 @@ module.exports =
applicantID = req.query.applicant
return next() unless applicantID
throw new errors.UnprocessableEntity('Bad applicant id') unless utils.isID(applicantID)
throw new errors.Forbidden('May not fetch for anyone but yourself') unless req.user.id is applicantID
throw new errors.Forbidden('May not fetch for anyone but yourself') unless req.user?.id is applicantID
trialRequests = yield TrialRequest.find({applicant: mongoose.Types.ObjectId(applicantID)})
trialRequests = (tr.toObject({req: req}) for tr in trialRequests)
res.status(200).send(trialRequests)