Questions tagged [connect-mongo]

100 questions
2
votes
1 answer

Node-gyp Connect-mongo on Amazon AWS EC2 Linux

I can't get connect-mongo to install on my EC2 instance. Has to do with node-gyp not having access to "/root/.node-gyp/0.10.40" - which is stange because the installed Node version is 4.2.1. The folder "/root/.node-gyp/" doesn't even exit on the…
ChrisRich
  • 8,300
  • 11
  • 48
  • 67
2
votes
1 answer

Mongoose - Searching Schema via findOne() unsuccessfully

In setting up a sessionStore via MongoDB for express-session, I'm having a little trouble using the findOne() function to verify that a user's information is valid and recent. var session = require('express-session'); var mongoStore =…
signus
  • 1,118
  • 14
  • 43
2
votes
1 answer

Handle database error when using connect-mongo

I've got a fairly standard connect-mongo setup mongoose is initialised / connected prior to this app.use(express.session({ secret: "sfdgsdgsdfg", store: new MongoSessionStore({db: mongoose.connection.db}) })); This works fine. However…
Alex
  • 37,502
  • 51
  • 204
  • 332
1
vote
0 answers

connect-mongo middleware creates a new database which includes sessions collection. NodeJS-Express-MongoDB

I use connect-mongo and express-session to store sessions in my database. It works fine on my local mongodb, but when it comes to MongoDB Atlas, the middleware creates a new database named test and places sessions collection in it. I want the…
codex
  • 11
  • 2
1
vote
1 answer

how to use connect-mongo version 4x with express-session. I'm getting errors

I am getting errors while trying to save sessions on MongoDB const MongoStore = require('connect-mongo'); const connectDB = require('./config/db'); const { connection } = require('mongoose'); app.use( session({ secret: 'some…
1
vote
4 answers

TypeError: Class constructor MongoStore cannot be invoked without 'new'

I'm creating a Next.js web app.... In my app.js file inside the server folder I have the following code: const express = require("express"); const next = require("next"); const expressValidator = require("express-validator"); const mongoose =…
preston
  • 3,721
  • 6
  • 46
  • 78
1
vote
1 answer

How to update express session outside of the request with connect mongo?

I am building an integration with Express Session and I am trying to authenticate the user in a separate webhook. So I need a way to update the user session outside of the request since it would be a different request. What I did is I passed the…
Anthony Kung
  • 1,025
  • 3
  • 12
  • 22
1
vote
0 answers

Cannot get value of req.user for Passport.js

I spent hours figuring things out why I cannot get the value of req.user when Passport.js serialized a user. But magically, when I deleted the database collection that holds the session, it worked again. My stack: Vue.js Express Mongoose MongoDb (I…
1
vote
0 answers

All active session in mongoDB express-session

How can i get all active sessions using mongo store with express-session in nodejs. What i have tried is: store.all((err,session)=>{ console.log(session); }) But its in the same file where i have initialised mongo store, but i'm unable to use this…
1
vote
2 answers

req.session.destroy has no effect

I have a NextJS client running on localhost:3001 and a Express/MongoDB server running on localhost:3000. For authentication I'm using express-session with connect-mongo like so: app.use(session({ secret: 'jordan-peterson-is-a-fraud', resave:…
o01
  • 5,191
  • 10
  • 44
  • 85
1
vote
2 answers

Apollo-server-express Session undefined problem

Hello I want to make session with ApolloServer and Express but when i get console log from req.session, it gives me undefined. Whats the problem?? When i get console log from req.session inside app.get, i get my results. Inside Mongodb compass i can…
1
vote
1 answer

Whats the equivalent of express.js "app.use()" in core node.js?

I am trying to use sessions in node.js, for that, i have to use connect-mongo package but in its documentation its been used with express's middleware function app.use() what if I want to use it in a project which does not use any framework like…
Hakimuddin
  • 90
  • 8
1
vote
0 answers

How to call SerializeUser manually in passport.js?

I'm on a quest to update user's sessions when their user document is modified by someone other than them. I was able to load the session and modify it, but is there a way to manually tell passport to reserialize the user? I need to refresh the data…
stackers
  • 2,701
  • 4
  • 34
  • 66
1
vote
2 answers

How to find and edit a session with express-session and connect-mongo?

I use express-session and connect-mongo to deal with user sessions. I need to figure out how to search the sessions database for a specific user and update it. I've tried querying the database with a fake schema and am able to find it, but when I…
stackers
  • 2,701
  • 4
  • 34
  • 66
1
vote
1 answer

what would be the correct way how to manage multiple logins from one user account in nodejs, express.js?

I'm using express-session, passport and connect-mongo for save sessions in mongodb. my package.json "dependencies": { "axios": "^0.18.0", "bcrypt": "^3.0.5", "body-parser": "^1.18.3", "bootstrap": "^4.3.1", …