From 90fe02430c828b0d99d5f60c3073c54278d85236 Mon Sep 17 00:00:00 2001 From: nanalelfe Date: Fri, 22 Jul 2016 07:33:52 -0400 Subject: Cleaned up the routing for users. Header changeable depending on whether user is logged in or not. Logout option. --- app.js | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'app.js') diff --git a/app.js b/app.js index 8b469f9..a96a932 100644 --- a/app.js +++ b/app.js @@ -12,6 +12,7 @@ var passport = require('passport'); var flash = require('connect-flash'); var routes = require('./routes/index'); +var userRoutes = require('./routes/user'); var app = express(); // Templating engine, we are using handlebars @@ -39,8 +40,17 @@ require('./config/passport'); // simply need to load it /*LOADS ALL STATIC FILES FROM THE DIRECTORY __dirname*/ app.use(express.static(__dirname)); + +// Needed to style the header based on the whether the user is signed in or not +// Gives errors for admin - need to figure out +app.use(function(req, res, next) { + res.locals.login = req.isAuthenticated(); // global variable + next(); +}); + // Allows us to customize express routing // in a separate file. +app.use('/user', userRoutes); app.use('/', routes); module.exports = app; -- cgit v1.2.3