github.js 814 B

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