Guest User

Untitled

a guest
Jun 24th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. passport.use(
  2. new FacebookStrategy(
  3. {
  4. clientID: config.facebookAuth.clientID,
  5. clientSecret: config.facebookAuth.clientSecret,
  6. callbackURL: config.facebookAuth.callbackURL,
  7. profileFields: [
  8. 'id',
  9. 'displayName',
  10. 'picture.width(200).height(200)',
  11. 'first_name',
  12. 'middle_name',
  13. 'last_name',
  14. 'email',
  15. ],
  16. },
  17. (accessToken, refreshToken, profile, done) => {
  18. process.nextTick(async () => {
  19. const facebookUser = {
  20. id: Math.random(),
  21. userName: profile.displayName,
  22. email: profile.emails[0].value,
  23. imgUrl: profile.photos[0].value,
  24. imgHeight: 200,
  25. imgWidth: 200,
  26. userProfileId: profile.id,
  27. };
  28. await getAsync('usersMockDatabase').then((users) => {
  29. // save new user into database
  30. const currUsers = JSON.parse(users);
  31. currUsers.push(facebookUser);
  32. db.set('usersMockDatabase', JSON.stringify(currUsers));
  33. });
  34. return done(null, facebookUser);
  35. });
  36. },
  37. ),
  38. );
Add Comment
Please, Sign In to add comment