From 3aa171fbaf05d0ee5b82673443da51ed43719475 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Fri, 25 Sep 2015 17:36:53 -0400 Subject: moving things around --- bucky/util/middleware.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 bucky/util/middleware.js (limited to 'bucky/util/middleware.js') diff --git a/bucky/util/middleware.js b/bucky/util/middleware.js new file mode 100644 index 0000000..a744c89 --- /dev/null +++ b/bucky/util/middleware.js @@ -0,0 +1,23 @@ +var middleware = module.exports = { + + ensureAuthenticated: function (req, res, next) { + if (! req.isAuthenticated()) { + req.session.returnTo = req.path + return res.redirect('/login') + } + next() + }, + + ensureLocals: function (req, res, next) { + res.locals.csrfToken = req.csrfToken() + res.locals.title = "bucky" + if (req.isAuthenticated()) { + res.locals.show_header = true + } + else { + res.locals.show_header = false + } + next() + }, + +} \ No newline at end of file -- cgit v1.2.3-70-g09d2