Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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);
- });
- },
- ),
- );
Add Comment
Please, Sign In to add comment