facebook.js 694 B

1234567891011121314151617181920212223242526
  1. 'use strict'
  2. /* global wiki */
  3. // ------------------------------------
  4. // Facebook Account
  5. // ------------------------------------
  6. const FacebookStrategy = require('passport-facebook').Strategy
  7. module.exports = (passport, conf) => {
  8. passport.use('facebook',
  9. new FacebookStrategy({
  10. clientID: conf.clientId,
  11. clientSecret: conf.clientSecret,
  12. callbackURL: conf.callbackURL,
  13. profileFields: ['id', 'displayName', 'email']
  14. }, function (accessToken, refreshToken, profile, cb) {
  15. wiki.db.User.processProfile(profile).then((user) => {
  16. return cb(null, user) || true
  17. }).catch((err) => {
  18. return cb(err, null) || true
  19. })
  20. }
  21. ))
  22. }