次の例を参照しています。
https://github.com/jaredhanson/passport-local/blob/master/examples/login/app.js
具体的には、次のコード:
app.post('/login',
passport.authenticate('local', { failureRedirect: '/login', failureFlash: true }),
function(req, res) {
res.redirect('/');
});
投稿されたコードは問題なく動作します。ただし、次のようにしてリファクタリングしようとすると:
app.post('/login',
authenticate,
function(req, res) {
res.redirect('/');
});
function authenticate() {
return passport.authenticate('local', { failureRedirect:'/fail', failureFlash:true });
}
物事はもう機能しません。私は何を間違っていますか?