diff --git a/messages/bun.lock b/messages/bun.lock index b28d57d..2d1f277 100644 --- a/messages/bun.lock +++ b/messages/bun.lock @@ -5,14 +5,14 @@ "name": "KeyNotes.App", "dependencies": { "KeyNotes.App": ".", - "bcryptjs": "latest", - "connect-sqlite3": "latest", - "ejs": "latest", - "express": "latest", - "express-session": "latest", - "express-validator": "latest", - "passport": "latest", - "passport-local": "latest", + "bcryptjs": "^3.0.2", + "connect-sqlite3": "^0.9.15", + "ejs": "^3.1.10", + "express": "^4.21.2", + "express-session": "^1.18.1", + "express-validator": "^7.2.1", + "passport": "^0.7.0", + "passport-local": "^1.0.0", }, }, }, diff --git a/messages/src/app.js b/messages/src/app.js index 1d7f02f..2b432ca 100644 --- a/messages/src/app.js +++ b/messages/src/app.js @@ -20,7 +20,7 @@ app.use( session({ store: new SQLiteStore({ dir: "./src/db/", db: "keynotes.db" }), secret: "keynotes", - cookie: { maxAge: 7 * 24 * 60 * 60 * 1000, sameSite: "strict" }, + cookie: { maxAge: 7 * 24 * 60 * 60 * 1000 }, saveUninitialized: false, resave: false, }), diff --git a/messages/src/controllers/authController.js b/messages/src/controllers/authController.js index a4bf0f4..f5e0219 100644 --- a/messages/src/controllers/authController.js +++ b/messages/src/controllers/authController.js @@ -3,11 +3,9 @@ const db = require("../models/query"); const { validationResult } = require("express-validator"); function loginGet(req, res, next) { - console.log(req.user, req.session.cookie); - console.table(req.session); - if (!req.user && req.session.id) { - req.session.id = null; - } + // if (!req.user && req.session.id) { + // req.session.id = null; + // } res.render("login", { pageTitle: "InspiredCliches | Login", errors: req.session.messages, @@ -15,11 +13,18 @@ function loginGet(req, res, next) { } function logOut(req, res, next) { - res.clearCookie("connect.sid", { path: "/" }); req.logout((err) => { - if (err) return next(err); + if (err) { + return next(err); + } + req.session.destroy((err) => { + if (err) { + return next(err); + } + res.clearCookie("connect.sid"); // Clear the session cookie + res.redirect("/"); + }); }); - res.redirect("/"); } function signUpGet(req, res, next) { diff --git a/messages/src/controllers/indexController.js b/messages/src/controllers/indexController.js index eb4dce6..97a3b16 100644 --- a/messages/src/controllers/indexController.js +++ b/messages/src/controllers/indexController.js @@ -32,7 +32,6 @@ function addLike(req, res) { function addNotePost(req, res) { const { message, media } = req.body; - console.log("add note post"); if (res.locals.currentUser) { const userId = res.locals.currentUser.user_id;