diff --git a/app.js b/app.js index a26d0bbfb7..34ca3600d6 100755 --- a/app.js +++ b/app.js @@ -47,6 +47,10 @@ app.use(express.methodOverride()); app.use(express.session({ secret: '0000' })); app.use(passport.initialize()); app.use(passport.session()); +app.use(function(req, res, next) { + res.locals.user = req.user; + next(); +}); app.use(flash()); app.use(less({ src: __dirname + '/public', compress: true })); app.use(app.router); diff --git a/controllers/api.js b/controllers/api.js index e0ff850484..054c2ac109 100644 --- a/controllers/api.js +++ b/controllers/api.js @@ -19,8 +19,7 @@ var Twit = require('twit'); */ exports.getApi = function(req, res) { res.render('api', { - title: 'API Browser', - user: req.user + title: 'API Browser' }); }; @@ -54,7 +53,6 @@ exports.getFoursquare = function(req, res) { if (err) return next(err); res.render('api/foursquare', { title: 'Foursquare API', - user: req.user, trendingVenues: results.trendingVenues, venueDetail: results.venueDetail, userCheckins: results.userCheckins @@ -78,8 +76,7 @@ exports.getTumblr = function(req, res) { res.render('api/tumblr', { title: 'Tumblr API', blog: data.blog, - photoset: data.posts[0].photos, - user: req.user + photoset: data.posts[0].photos }); }); }; @@ -108,8 +105,7 @@ exports.getFacebook = function(req, res, next) { res.render('api/facebook', { title: 'Facebook API', me: results.getMe, - friends: results.getMyFriends, - user: req.user + friends: results.getMyFriends }); }); }; @@ -128,8 +124,7 @@ exports.getScraping = function(req, res, next) { }); res.render('api/scraping', { title: 'Web Scraping', - links: links, - user: req.user + links: links }); }); }; @@ -145,8 +140,7 @@ exports.getGithub = function(req, res) { repo.show(function(err, repo) { res.render('api/github', { title: 'GitHub API', - repo: repo, - user: req.user + repo: repo }); }); @@ -158,8 +152,7 @@ exports.getGithub = function(req, res) { */ exports.getAviary = function(req, res) { res.render('api/aviary', { - title: 'Aviary API', - user: req.user + title: 'Aviary API' }); }; @@ -174,8 +167,7 @@ exports.getNewYorkTimes = function(req, res) { var bestsellers = JSON.parse(body); res.render('api/nyt', { title: 'New York Times API', - books: bestsellers.results, - user: req.user + books: bestsellers.results }); }); }; @@ -231,8 +223,7 @@ exports.getLastfm = function(req, res) { }; res.render('api/lastfm', { title: 'Last.fm API', - artist: artist, - user: req.user + artist: artist }); }); }; @@ -252,7 +243,6 @@ exports.getTwitter = function(req, res) { T.get('search/tweets', { q: 'hackathon since:2013-01-01', geocode: '40.71448,-74.00598,5mi', count: 50 }, function(err, reply) { res.render('api/twitter', { title: 'Twitter API', - user: req.user, tweets: reply.statuses }); }); diff --git a/controllers/contact.js b/controllers/contact.js index 3a5115b768..c9ca405569 100644 --- a/controllers/contact.js +++ b/controllers/contact.js @@ -8,7 +8,6 @@ var sendgrid = require('sendgrid')(secrets.sendgrid.user, secrets.sendgrid.pass exports.getContact = function(req, res) { res.render('contact', { title: 'Contact', - user: req.user, success: req.flash('success'), error: req.flash('error') }); diff --git a/controllers/home.js b/controllers/home.js index 70f21890b4..1f1f77e2f7 100644 --- a/controllers/home.js +++ b/controllers/home.js @@ -4,7 +4,6 @@ */ exports.index = function(req, res) { res.render('index', { - user: req.user, title: 'Home' }); }; diff --git a/controllers/user.js b/controllers/user.js index e49d563d55..a3f112d902 100644 --- a/controllers/user.js +++ b/controllers/user.js @@ -12,7 +12,6 @@ var User = require('../models/User'); exports.getAccount = function(req, res) { res.render('account', { title: 'Account Management', - user: req.user, success: req.flash('success'), error: req.flash('error') }); @@ -88,7 +87,6 @@ exports.getLogin = function(req, res) { if (req.user) return res.redirect('back'); res.render('login', { title: 'Login', - user: req.user, messages: req.flash('messages') }); }; @@ -119,7 +117,6 @@ exports.getSignup = function(req, res) { if (req.user) return res.redirect('back'); res.render('signup', { title: 'Create Account', - user: req.user, messages: req.flash('messages') }); };