From f39b8555fa6ce834e0e47944bbc47004387fa418 Mon Sep 17 00:00:00 2001 From: nicoagostini Date: Mon, 5 May 2025 18:59:59 -0700 Subject: [PATCH] fix/session check fixed --- app.js | 4 ---- src/auth/authentication.js | 6 ++++++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app.js b/app.js index 958ede4..5324680 100644 --- a/app.js +++ b/app.js @@ -65,10 +65,6 @@ app.get('/aboutUs', (req, res) => { return res.status(status.Ok); }); -app.get('/logout', (req, res) => { - req.session.destroy(); - return res.redirect('/login'); -}); // Initialize database and start app initDatabase().then(() => { diff --git a/src/auth/authentication.js b/src/auth/authentication.js index 559b7ca..068f789 100644 --- a/src/auth/authentication.js +++ b/src/auth/authentication.js @@ -13,6 +13,12 @@ module.exports = (users) => { }); router.post("/login", async (req, res) => { + + if (req.session.authenticated) { + res.redirect("/home"); + return res.status(status.Ok); + } + const credentialSchema = joi.object({ email: joi.string().email().required(), password: joi.string().max(20).required(),