fixed crash bug if user was logged off

This commit is contained in:
MrRenter
2015-03-17 03:15:00 -04:00
parent 9a5c7a0ce6
commit 1320a14851

View File

@ -137,15 +137,18 @@ exports.returnIndividualStory = function(req, res, next) {
return res.redirect('../stories/' + dashedNameFull); return res.redirect('../stories/' + dashedNameFull);
} }
var userVoted = false;
try {
var votedObj = story.upVotes.filter(function(a){ var votedObj = story.upVotes.filter(function(a){
return a['upVotedByUsername'] === req.user['profile']['username']; return a['upVotedByUsername'] === req.user['profile']['username'];
}) })
var userVoted = false;
if (votedObj.length > 0){ if (votedObj.length > 0){
userVoted = true; userVoted = true;
} }
} catch(err){
userVoted = false;
}
res.render('stories/index', { res.render('stories/index', {
title: story.headline, title: story.headline,
link: story.link, link: story.link,