diff options
Diffstat (limited to 'middlewares/requireAuth.js')
-rw-r--r-- | middlewares/requireAuth.js | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/middlewares/requireAuth.js b/middlewares/requireAuth.js new file mode 100644 index 0000000..3cf10ec --- /dev/null +++ b/middlewares/requireAuth.js @@ -0,0 +1,8 @@ +function requireAuth(req, res, next) { + if (req.session.userId) { + next(); + } + res.redirect(302, "/login"); +} + +export default requireAuth; |