JavaScript Answers

How to add Node Express Passport error handling?

Spread the love

To add Node Express Passport error handling, we use the middleware returned by passport.authenticate.

For instance, we write
  passport.authenticate("local", {
    successRedirect: "/loggedin",
    failureRedirect: "/login",
    failureFlash: true,

to call passport.authenticate to return the authentication middleware.

We use that as the argument of post to make it use Passport authentication.

We set the successRedirect and failureRedirect properties to set the redirect destination in both cases.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published.