10 lines
304 B
JavaScript
10 lines
304 B
JavaScript
|
// Make sure the user is logged in
|
||
|
// Redirect to login page and store the current path in the session for redirecting later
|
||
|
function ensureLogin (req, res, next) {
|
||
|
if (req.session.user) return next()
|
||
|
req.session.redirectUri = req.originalUrl
|
||
|
res.redirect('/login')
|
||
|
}
|
||
|
|
||
|
module.exports = ensureLogin
|