Display passport.js authentication error message in view Display passport.js authentication error message in view express express

Display passport.js authentication error message in view


At first glance, looks like sails is using Express 3.0. Per the Passport docs (http://passportjs.org/docs), you will need to explicitly add middleware to support flash (they recommend https://github.com/jaredhanson/connect-flash).


Not a passport expert here, but according to this all you need to do is to re-render the login view with req.flash('error'):

res.render("login", {error: req.flash("error")});

And then in the handlebars template, display the error:

{{ error }}


Don't know if this might help you, Brad.

https://stackoverflow.com/a/25151855/3499069

I think in your serializeUser call you need it to be user[0].id, but I've moved away from Passport recently, so I could be wrong.