Skip to content Skip to sidebar Skip to footer

Node.js Passport Not Calling Next Function

I'm building an application using Node that uses Passport.js to handle user login using a local database. So I have the following code that gets called when a user goes to /profile

Solution 1:

passport.authenticate() is meant to handle the actual authentication; in other words, to take the login credentials and pass them to the strategy. It's not meant to pass along requests if they are already authenticated, which is what you're trying to use it for.

Instead, you want to use something like connect-ensure-login to guard routes for which a user has to be logged in.

See also this Passport example project.

Post a Comment for "Node.js Passport Not Calling Next Function"