jaredhanson / passport-facebook

Facebook authentication strategy for Passport and Node.js.
https://www.passportjs.org/packages/passport-facebook/?utm_source=github&utm_medium=referral&utm_campaign=passport-facebook&utm_content=about
MIT License
1.3k stars 446 forks source link

Parameters passed to verify callback are wrong in docs #190

Open wzup opened 7 years ago

wzup commented 7 years ago

Your docs are wrong, it misinforms.

In your docs

  function(accessToken, refreshToken, profile, cb) {
    User.findOrCreate({ facebookId: profile.id }, function (err, user) {
      return cb(err, user);
    });
  }

In real life The first is a request. The second is a token. Notice, only one token.. And the third parameter is undefined

function(request, token, something_undefined, profile, done) {
corydeppen commented 6 years ago

Maybe not wrong, but rather incomplete. According to the Passport documentation:

To avoid this, set the strategy's passReqToCallback option to true. With this option enabled, req will be passed as the first argument to the verify callback.

So it looks like there should be two signatures for the verify callback.

fega commented 6 years ago

Hello, I'm having the same problem, where passReqToCallback looks set true as default

the problem that I see is that if you fix the problem,a lot of people could be affected.

twelve17 commented 6 years ago

I did not see this behavior in version 2.1.1 of this library. Until just recently, I was not at all specifying passReqToCallback in the passport-facebook Strategy call, and my verify function had the signature (accessToken, refreshToken, profile, callback). Later, I added passReqToCallback to the Strategy, and once changing the verify function to have (req, accessToken, refreshToken, profile, callback), the arguments were being passed in as expected.