How do I check the ID of the user who just logged in with passport.js?

Viewed 171

I use passport.js of Express Framework to authenticate the login. I want to get the data of user in database after log in. I set up a middleware to check if the user is logged in then adjust res.locals.user, my source like this: enter image description here

My problem is that even though I'm logged in correctly, I can't get the data:

enter image description here

I think my _id variable at line 10 is wrong. How can I solve this problem ?

1 Answers

If you can please provide more code. But believe one possible error is on line 10 and must be:

req.session.passport.user.id

Sorry that i wrote as an cant write comments atm.

Related