You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
844 B

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