From 7b31c40676204f22b6d71777d381f55419720d93 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Sat, 16 May 2020 00:12:31 -0400 Subject: [PATCH] Prevent userID errors --- src/routes/voteOnSponsorTime.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/routes/voteOnSponsorTime.js b/src/routes/voteOnSponsorTime.js index 6dbdb6c..5025fbb 100644 --- a/src/routes/voteOnSponsorTime.js +++ b/src/routes/voteOnSponsorTime.js @@ -266,7 +266,13 @@ module.exports = async function voteOnSponsorTime(req, res) { //for each positive vote, see if a hidden submission can be shown again if (incrementAmount > 0 && voteTypeEnum === voteTypes.normal) { //find the UUID that submitted the submission that was voted on - let submissionUserID = db.prepare("SELECT userID FROM sponsorTimes WHERE UUID = ?").get(UUID).userID; + let submissionUserID = db.prepare("SELECT userID FROM sponsorTimes WHERE UUID = ?").get(UUID)?.userID; + + if (!submissionUserID) { + // They are voting on a non-existent submission + res.status("Voting on a non-existent submission").send(400); + return; + } //check if any submissions are hidden let hiddenSubmissionsRow = db.prepare("SELECT count(*) as hiddenSubmissions FROM sponsorTimes WHERE userID = ? AND shadowHidden > 0").get(submissionUserID);