Auth0 React, Node, & Passport - session.passport.user undefined

Hi,

I have inherited an app that I am trying to get to work and having trouble. The app uses React, Node, and Passport. My understanding of the workflow is as follows:

  1. user clicks “login” in the React app
  2. React calls /login/auth0 on my Node server
  3. my Node server calls Auth0
  4. Auth0 authenticates the user
  5. Auth0 returns to my Node server using the callback url

Step 4 above works, because I am successfully redirected to the Auth0 login screen and can login.

Step 5 is where I run into the issue - I get redirected back to the server and can debug a breakpoint where it hits (in my postAuthenticationRouter.js) and I can see that req.session.passport.user is undefined).

I have tried some pieces of debugging and I am totally stuck. At this point, I am thinking of maybe trying to look at the req object to maybe find some clues that could indicate what is missing or going wrong. What I see of req.session is the following:

Where in that object is the authenticated user’s information supposed to be?

As far as I can tell, the Auth0 part is happening correctly, since it redirects me back to my app. I am confused though, because as far as I can tell, the response from Auth0 is not coming back with anything.

Alternatively, does anyone have a tip of where I could put a breakpoint on my server to see the response coming from Auth0 to just spot check that it has the information about the user?

Thank you so much for the help! Please let me know if I can provide any other details!

The issue here ended up being my version of Node.js was 10.x and the one from the origin machine was 14.x. Once I updated the version of Node on my machine, this worked!

1 Like

Perfect glad to hear that and thanks for sharing with the rest of community!