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.

31 lines
783 B

  1. 'use strict'
  2. /* global wiki */
  3. // ------------------------------------
  4. // GitHub Account
  5. // ------------------------------------
  6. const GitHubStrategy = require('passport-github2').Strategy
  7. module.exports = {
  8. key: 'github',
  9. title: 'GitHub',
  10. props: ['clientId', 'clientSecret', 'callbackURL'],
  11. init (passport, conf) {
  12. passport.use('github',
  13. new GitHubStrategy({
  14. clientID: conf.clientId,
  15. clientSecret: conf.clientSecret,
  16. callbackURL: conf.callbackURL,
  17. scope: ['user:email']
  18. }, (accessToken, refreshToken, profile, cb) => {
  19. wiki.db.User.processProfile(profile).then((user) => {
  20. return cb(null, user) || true
  21. }).catch((err) => {
  22. return cb(err, null) || true
  23. })
  24. }
  25. ))
  26. }
  27. }