authentication.js 687 Bytes
Newer Older
1
/* global WIKI */
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17

// ------------------------------------
// Dropbox Account
// ------------------------------------

const DropboxStrategy = require('passport-dropbox-oauth2').Strategy

module.exports = {
  init (passport, conf) {
    passport.use('dropbox',
      new DropboxStrategy({
        apiVersion: '2',
        clientID: conf.clientId,
        clientSecret: conf.clientSecret,
        callbackURL: conf.callbackURL
      }, (accessToken, refreshToken, profile, cb) => {
18
        WIKI.models.users.processProfile(profile).then((user) => {
19 20 21 22 23 24 25 26
          return cb(null, user) || true
        }).catch((err) => {
          return cb(err, null) || true
        })
      })
    )
  }
}