Я изучаю (довольно тяжело), модуль «Паспорт». Я указал флеш-сообщения в своей "Стратегии" следующим образом:
passport.use(
new Strategy(function(username, password, cb) {
if (username !== "riko") {
// console.info("Incorrect User");
return cb(null, false, { message: "Icorrect user!" });
}
if (password !== "kote") {
// console.info("Incorrect Password");
return cb(null, false, { message: "Icorrect password!" });
}
return cb(null, { username: "riko", passpord: "kote", chemer: "memer" });
})
);
app.post(
"/Login",
passport.authenticate("local", {
successRedirect: "/User",
failureFlash: true
}),
function(req, res) {
console.info("LOGIN POST!");
res.redirect("/Home");
// res.sendFile(path.join(__dirname, "client/build", "index.html"));
}
);
Я читал в документации, что эти флэш-сообщения можно использовать для информирования пользователя о статусе аутентификации:
Redirects are often combined with flash messages in order to display status information to the user.
Setting the failureFlash option to true instructs Passport to flash an error message using the message given by the strategy's verify callback, if any. This is often the best approach, because the verify callback can make the most accurate determination of why authentication failed.
Проблема в том, что я не знаю, как получить доступ к этим флэш-сообщениям ни в бэкэнде, ни во внешнем интерфейсе.



![Безумие обратных вызовов в javascript [JS]](https://i.imgur.com/WsjO6zJb.png)


Вы можете получить доступ к флэш-сообщениям с помощью параметра запроса (req).
app.get('/User', function (req, res) {
res.render('User', { message: req.flash('message') });
});