From 1320a1485123eaa758c3f69c8d317b5c700225f0 Mon Sep 17 00:00:00 2001 From: MrRenter Date: Tue, 17 Mar 2015 03:15:00 -0400 Subject: [PATCH] fixed crash bug if user was logged off --- controllers/story.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/controllers/story.js b/controllers/story.js index 97f31d16cd..c8f1f965c4 100644 --- a/controllers/story.js +++ b/controllers/story.js @@ -137,15 +137,18 @@ exports.returnIndividualStory = function(req, res, next) { return res.redirect('../stories/' + dashedNameFull); } - - var votedObj = story.upVotes.filter(function(a){ - return a['upVotedByUsername'] === req.user['profile']['username']; - }) var userVoted = false; - if (votedObj.length > 0){ - userVoted = true; - } + try { + var votedObj = story.upVotes.filter(function(a){ + return a['upVotedByUsername'] === req.user['profile']['username']; + }) + if (votedObj.length > 0){ + userVoted = true; + } + } catch(err){ + userVoted = false; + } res.render('stories/index', { title: story.headline, link: story.link,