function checkAuth(req, res, next) { if (!req.session.auth) // res.send('You are not authorized to view this page'); res.redirect('/'); else { res.header('Cache-Control', 'no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0'); next(); } } module.exports = checkAuth; // https://stackoverflow.com/questions/7990890/how-to-implement-login-auth-in-node-js // look aT JWT BIT AT BOTTOM