passport-facebook-token
passport-facebook-token copied to clipboard
Syntax for Sails for Facebook Authentication
I used the sails framework to authenticate a user with my custom facebook token strategy. It works perfectly. I copied this snippet of code from github to make it work, However, I don't quite understand the syntax of that last part which has (req, res); at the end. Obviously it's referring to request and response, but why is that line of code there, it seems to be in an awkward place. Authentication fails if I exclude that line of code. It must be important so I just need to figure out what it is doing .
module.exports = {
facebook: function(req, res) {
passport.authenticate('facebook-token', function(error, user, info) {
res.ok();
})
(req, res);
}
};
@jadslim313 passport.authenticate() returns a function, which accepts req and res arguments. When you are using it in Express middlewares, it calls automatically. But, in Sails, you need to call it by yourself.
That makes sense ! I ended up removing res only having (req) in there. It worked just as fine, which makes sense as the token is in the request. However, what would the purpose of res be in this case? Just to make sure I'm not missing anything.
@rslim087g you can remove res, I leave it just for consistency.