What does:
someFunction(args)(moreArgs);
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);
});
passport.authenticate
local
(req, res, next)
someFunction(args)(moreArgs);
()
someFunction(args)
returns a function, so (moreArgs)
is just calling that returned function.
E.g:
function foo(a) {
console.log(a);
function bar(b,c){
console.log(b, c);
}
return bar;
}
foo(20)("Thou shalt", "not steal");