Skip to content

Instantly share code, notes, and snippets.

@tj
Created April 27, 2012 01:33
Show Gist options
  • Save tj/2504880 to your computer and use it in GitHub Desktop.
Save tj/2504880 to your computer and use it in GitHub Desktop.
function tagsMiddleware(req, res, next) {
res.local('tags', {});
if (req.session.logged_in) {
User.findOne({ _id: req.session.user_id }, function (err, docs) {
if (!err) {
res.local('tags', {
ignored: docs.ignored_tags,
favorite: docs.favorite_tags
});
}
next();
});
} else {
next();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment