diff --git a/backend/config/passportConfig.js b/backend/config/passportConfig.js index 842f50ca..b4a92d19 100644 --- a/backend/config/passportConfig.js +++ b/backend/config/passportConfig.js @@ -9,7 +9,7 @@ passport.use( try { const user = await User.findOne( {email} ); if (!user) { - return done(null, false, { message: 'Email is invalid '}); + return done(null, false, { message: 'Email is invalid ' }); } const isMatch = await user.comparePassword(password); @@ -18,7 +18,7 @@ passport.use( } return done(null, { - id : user._id.toString(), + id: user._id.toString(), username: user.username, email: user.email }); diff --git a/backend/server.js b/backend/server.js index 48d6ccfb..b73d5446 100644 --- a/backend/server.js +++ b/backend/server.js @@ -28,10 +28,16 @@ app.use(cors({ // Middleware app.use(bodyParser.json()); + app.use(session({ secret: process.env.SESSION_SECRET, resave: false, saveUninitialized: false, + cookie: { + maxAge: 24 * 60 * 60 * 1000, + secure: process.env.NODE_ENV === "production", + sameSite: process.env.NODE_ENV === "production" ? "none" : "lax" + } })); app.use(passport.initialize()); app.use(passport.session());