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.

34 lines
878 B

  1. /* global WIKI */
  2. // ------------------------------------
  3. // Dropbox Account
  4. // ------------------------------------
  5. const DropboxStrategy = require('passport-dropbox-oauth2').Strategy
  6. const _ = require('lodash')
  7. module.exports = {
  8. init (passport, conf) {
  9. passport.use('dropbox',
  10. new DropboxStrategy({
  11. apiVersion: '2',
  12. clientID: conf.clientId,
  13. clientSecret: conf.clientSecret,
  14. callbackURL: conf.callbackURL
  15. }, async (accessToken, refreshToken, profile, cb) => {
  16. try {
  17. const user = await WIKI.models.users.processProfile({
  18. profile: {
  19. ...profile,
  20. picture: _.get(profile, '_json.profile_photo_url', '')
  21. },
  22. providerKey: 'dropbox'
  23. })
  24. cb(null, user)
  25. } catch (err) {
  26. cb(err, null)
  27. }
  28. })
  29. )
  30. }
  31. }