Skip to content

Instantly share code, notes, and snippets.

@AndrejGajdos
Last active June 24, 2018 07:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AndrejGajdos/1599721deaa4ec4d777b4d51fd51b433 to your computer and use it in GitHub Desktop.
Save AndrejGajdos/1599721deaa4ec4d777b4d51fd51b433 to your computer and use it in GitHub Desktop.
passport.use(
new FacebookStrategy(
{
clientID: config.facebookAuth.clientID,
clientSecret: config.facebookAuth.clientSecret,
callbackURL: config.facebookAuth.callbackURL,
profileFields: [
'id',
'displayName',
'picture.width(200).height(200)',
'first_name',
'middle_name',
'last_name',
'email',
],
},
(accessToken, refreshToken, profile, done) => {
process.nextTick(async () => {
const facebookUser = {
id: Math.random(),
userName: profile.displayName,
email: profile.emails[0].value,
imgUrl: profile.photos[0].value,
imgHeight: 200,
imgWidth: 200,
userProfileId: profile.id,
};
await getAsync('usersMockDatabase').then((users) => {
// save new user into database
const currUsers = JSON.parse(users);
currUsers.push(facebookUser);
db.set('usersMockDatabase', JSON.stringify(currUsers));
});
return done(null, facebookUser);
});
},
),
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment