0
votes

I am using Passport.js to authenticate user login. This is my code at the moment:

app.post('/login', passport.authenticate('local', {
  failureRedirect: '/login',
  successRedirect: "/secrets",
  failureMessage: "Incorrect password"
}));

Basically, if authentication succeeds it will direct to the "secrets" page; if authentication fails it will redirect back to "login" page.

The authentication works well in this case; however, when the authentication fails and it redirects back to the login page, I also want the failureMessage to display in a ejs template I have for the login page. How can I do that?

I want something like this in ejs (but this code does not work, of course):

<a> <%= failureMessage %> </a>