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.

26 lines
655 B

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