2
0

dropbox.js 802 B

123456789101112131415161718192021222324252627282930313233
  1. /* global WIKI */
  2. // ------------------------------------
  3. // Dropbox Account
  4. // ------------------------------------
  5. const DropboxStrategy = require('passport-dropbox-oauth2').Strategy
  6. module.exports = {
  7. key: 'dropbox',
  8. title: 'Dropbox',
  9. useForm: false,
  10. props: {
  11. clientId: String,
  12. clientSecret: String
  13. },
  14. init (passport, conf) {
  15. passport.use('dropbox',
  16. new DropboxStrategy({
  17. apiVersion: '2',
  18. clientID: conf.clientId,
  19. clientSecret: conf.clientSecret,
  20. callbackURL: conf.callbackURL
  21. }, (accessToken, refreshToken, profile, cb) => {
  22. WIKI.db.users.processProfile(profile).then((user) => {
  23. return cb(null, user) || true
  24. }).catch((err) => {
  25. return cb(err, null) || true
  26. })
  27. })
  28. )
  29. }
  30. }