Search code examples
mongoosepassport-local

Passport-local-mongoose how to get authentication error message?


I am using passport-local-mongoose for local authentication and cannot find a way to display authentication error message. The only mention of error messages in their documentation is in regard to overriding the default ones.

How can I find them?


Solution

  • After hours of digging, finally found that error messages can be accessed via error key on flash():

    router.get('/login',
        function(req, res) {
            res.render('login', { user: req.user, message: req.flash('error') });
        });