2019-04-22 01:43:33 +00:00
|
|
|
/* global WIKI */
|
|
|
|
|
|
|
|
// ------------------------------------
|
2020-08-30 05:36:17 +00:00
|
|
|
// Firebase Account
|
2019-04-22 01:43:33 +00:00
|
|
|
// ------------------------------------
|
|
|
|
|
2020-08-30 05:36:17 +00:00
|
|
|
// INCOMPLETE / TODO
|
|
|
|
|
|
|
|
const FirebaseStrategy = require('passport-github2').Strategy
|
2019-04-22 01:43:33 +00:00
|
|
|
const _ = require('lodash')
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
init (passport, conf) {
|
2022-03-26 01:17:04 +00:00
|
|
|
passport.use(conf.key,
|
2020-08-30 05:36:17 +00:00
|
|
|
new FirebaseStrategy({
|
2019-04-22 01:43:33 +00:00
|
|
|
clientID: conf.clientId,
|
|
|
|
clientSecret: conf.clientSecret,
|
|
|
|
callbackURL: conf.callbackURL,
|
|
|
|
scope: ['user:email']
|
2020-08-30 05:36:17 +00:00
|
|
|
}, async (req, accessToken, refreshToken, profile, cb) => {
|
2019-04-22 01:43:33 +00:00
|
|
|
try {
|
|
|
|
const user = await WIKI.models.users.processProfile({
|
2020-08-30 05:36:17 +00:00
|
|
|
providerKey: req.params.strategy,
|
2019-04-22 01:43:33 +00:00
|
|
|
profile: {
|
|
|
|
...profile,
|
|
|
|
picture: _.get(profile, 'photos[0].value', '')
|
2020-08-30 05:36:17 +00:00
|
|
|
}
|
2019-04-22 01:43:33 +00:00
|
|
|
})
|
|
|
|
cb(null, user)
|
|
|
|
} catch (err) {
|
|
|
|
cb(err, null)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
))
|
|
|
|
}
|
|
|
|
}
|