From 2611ded920a8345922346ed0d43e4efdd94401a1 Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Thu, 27 Oct 2022 23:56:29 +0200 Subject: Began implementing middlewares, session and auth --- middlewares/requireAuth.js | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 middlewares/requireAuth.js (limited to 'middlewares/requireAuth.js') 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; -- cgit v1.2.3