authentication.js 723 Bytes
Newer Older
1
/* global WIKI */
2 3 4 5 6 7 8

// ------------------------------------
// Facebook Account
// ------------------------------------

const FacebookStrategy = require('passport-facebook').Strategy

9 10 11 12 13 14 15 16 17
module.exports = {
  init (passport, conf) {
    passport.use('facebook',
      new FacebookStrategy({
        clientID: conf.clientId,
        clientSecret: conf.clientSecret,
        callbackURL: conf.callbackURL,
        profileFields: ['id', 'displayName', 'email']
      }, function (accessToken, refreshToken, profile, cb) {
18
        WIKI.models.users.processProfile(profile).then((user) => {
19 20 21 22 23 24 25
          return cb(null, user) || true
        }).catch((err) => {
          return cb(err, null) || true
        })
      }
      ))
  }
26
}