2018-03-05 15:49:36 -05:00
|
|
|
/* global WIKI */
|
2017-07-29 17:33:08 -04:00
|
|
|
|
|
|
|
// ------------------------------------
|
|
|
|
// GitHub Account
|
|
|
|
// ------------------------------------
|
|
|
|
|
|
|
|
const GitHubStrategy = require('passport-github2').Strategy
|
|
|
|
|
2017-09-10 23:00:03 -04:00
|
|
|
module.exports = {
|
|
|
|
init (passport, conf) {
|
|
|
|
passport.use('github',
|
|
|
|
new GitHubStrategy({
|
|
|
|
clientID: conf.clientId,
|
|
|
|
clientSecret: conf.clientSecret,
|
|
|
|
callbackURL: conf.callbackURL,
|
|
|
|
scope: ['user:email']
|
|
|
|
}, (accessToken, refreshToken, profile, cb) => {
|
2018-07-29 22:23:33 -04:00
|
|
|
WIKI.models.users.processProfile(profile).then((user) => {
|
2017-09-10 23:00:03 -04:00
|
|
|
return cb(null, user) || true
|
|
|
|
}).catch((err) => {
|
|
|
|
return cb(err, null) || true
|
|
|
|
})
|
|
|
|
}
|
|
|
|
))
|
|
|
|
}
|
2017-07-29 17:33:08 -04:00
|
|
|
}
|