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.29k stars 446 forks source link

profile and cb are flipped in callback function when defining strategy to use #248

Closed sbernheim4 closed 6 years ago

sbernheim4 commented 6 years ago

In regards to setting up a strategy, specifically the callback like so:

const Strategy = require('passport-facebook').Strategy;
passport.use(new Strategy({
    clientID: ****,
    clientSecret: ****,
    callbackURL: ****
},
    function(accessToken, refreshToken, profile, cb) {

        });
)

I believe in this example, the value of profile and cb are swapped. In my app running console.log(profile) prints out undefined whereas console.log(cb) prints out the actual profile information. For example:

{ id: '****',
  username: undefined,
  displayName: 'Sam Bernheim',
  name:
   { familyName: undefined,
     givenName: undefined,
     middleName: undefined },
  gender: undefined,
  profileUrl: undefined,
  provider: 'facebook',
  _raw: '{"name":"Sam Bernheim","id":"****"}',
  _json: { name: 'Sam Bernheim', id: '****' } }

This makes sense since I never defined cb. To me this means that the values just need to be flipped and the function should look like function(accessToken, refreshToken, cb, profile) or better yet the implementation should be fixed to keep the order consistent with the other strategies (assuming they work and don't have this problem as well)