auth0.js 813 B

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