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 votedObj = story.upVotes.filter(function(a){
return a['upVotedByUsername'] === req.user['profile']['username'];
})
var userVoted = false; var userVoted = false;
if (votedObj.length > 0){ try {
userVoted = true; 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', { res.render('stories/index', {
title: story.headline, title: story.headline,
link: story.link, link: story.link,