diff options
| author | nanalelfe <nargiza.nosirova@mail.utoronto.ca> | 2016-07-23 11:52:04 +0000 |
|---|---|---|
| committer | nanalelfe <nargiza.nosirova@mail.utoronto.ca> | 2016-07-23 11:52:04 +0000 |
| commit | 630c86aacf4594ffae2b13720e5b44f8b2557953 (patch) | |
| tree | 0b9736416efdad3166e4c67f4cd4a9df7919adbc /routes/admin.js | |
| parent | 41dca46235c15578aab159074c99c904597c5fb2 (diff) | |
Added route protection for the admin panel, and additional for user. Nav changes depending on admin/user
Diffstat (limited to 'routes/admin.js')
| -rw-r--r-- | routes/admin.js | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/routes/admin.js b/routes/admin.js index 35b208b..bdd4f9b 100644 --- a/routes/admin.js +++ b/routes/admin.js @@ -7,7 +7,9 @@ var passport = require('passport'); var csrfProtection = csrf(); router.use(csrfProtection); // router is protected -router.get('/', function(req,res){ + + +router.get('/', isAdmin, function(req,res){ res.render('admin', {csrfToken: req.csrfToken()}); }); @@ -102,3 +104,13 @@ function parseStringArray(input){ module.exports = router; + +/************** Route protection ********************/ + +function isAdmin(req, res, next) { + if (!req.user.email){ + return next(); + } + res.redirect('/'); +} + |
