Passport.js에 대한 사용자 지정 콜백 문제를 이해하는 데 문제가 있습니다. 끝에 (req, res, next)
을 이해하지 못합니다. 우리가 폐쇄로부터 이러한 가치를 가져야 하는가?Passportjs 콜백, 인수 이해
app.get('/login', function(req, res, next) {
passport.authenticate('local', function(err, user, info) {
if (err) { return next(err); }
if (!user) { return res.redirect('/login'); }
req.logIn(user, function(err) {
if (err) { return next(err); }
return res.redirect('/users/' + user.username);
});
})(req, res, next); //<=== What is the purpose of this?
});
자체 호출 기능입니다. req, res 및 next를 params로 전달하고 있습니다. https://jsfiddle.net/ccestd3o/ – yBrodsky