From e25333e36126521b1db26cd4fd65c87b10085b96 Mon Sep 17 00:00:00 2001 From: Rick Leir Date: Mon, 7 Oct 2019 12:08:56 -0400 Subject: [PATCH] fix null check The null check for 'quest' needs to be before the access. --- server/methods.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server/methods.js b/server/methods.js index 8779b6e8..f2dd9c55 100644 --- a/server/methods.js +++ b/server/methods.js @@ -342,12 +342,13 @@ Meteor.methods({ if (this.userId) { const email = Meteor.users.findOne({ _id: this.userId }).emails[0].address; const quest = Questions.findOne({ _id: id }); + + if (!quest) { return false; } const instanceid = quest.instanceid; const instance = Instances.findOne({ _id: instanceid, }); - - if (!email || !instance || !instance.admin || !quest) { return false; } + if (!email || !instance || !instance.admin) { return false; } if (email !== instance.admin && (instance.moderators.indexOf(email) === -1) && (quest.email !== email || !quest.posterLoggedIn)) { return false; }