github.js 797 B

123456789101112131415161718192021222324252627282930313233
  1. /* global WIKI */
  2. // ------------------------------------
  3. // GitHub Account
  4. // ------------------------------------
  5. const GitHubStrategy = require('passport-github2').Strategy
  6. module.exports = {
  7. key: 'github',
  8. title: 'GitHub',
  9. useForm: false,
  10. props: {
  11. clientId: String,
  12. clientSecret: String
  13. },
  14. init (passport, conf) {
  15. passport.use('github',
  16. new GitHubStrategy({
  17. clientID: conf.clientId,
  18. clientSecret: conf.clientSecret,
  19. callbackURL: conf.callbackURL,
  20. scope: ['user:email']
  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. }