2018-03-05 15:49:36 -05:00
|
|
|
/* global WIKI */
|
2017-07-29 17:33:08 -04:00
|
|
|
|
|
|
|
// ------------------------------------
|
|
|
|
// Microsoft Account
|
|
|
|
// ------------------------------------
|
|
|
|
|
2019-04-26 23:59:35 -04:00
|
|
|
const WindowsLiveStrategy = require('passport-microsoft').Strategy
|
|
|
|
const _ = require('lodash')
|
2017-07-29 17:33:08 -04:00
|
|
|
|
2017-09-10 23:00:03 -04:00
|
|
|
module.exports = {
|
|
|
|
init (passport, conf) {
|
2022-03-25 21:17:04 -04:00
|
|
|
passport.use(conf.key,
|
2017-09-10 23:00:03 -04:00
|
|
|
new WindowsLiveStrategy({
|
|
|
|
clientID: conf.clientId,
|
|
|
|
clientSecret: conf.clientSecret,
|
2019-04-26 23:59:35 -04:00
|
|
|
callbackURL: conf.callbackURL,
|
2020-08-30 01:36:17 -04:00
|
|
|
scope: ['User.Read', 'email', 'openid', 'profile'],
|
|
|
|
passReqToCallback: true
|
|
|
|
}, async (req, accessToken, refreshToken, profile, cb) => {
|
2019-04-21 21:43:33 -04:00
|
|
|
try {
|
|
|
|
const user = await WIKI.models.users.processProfile({
|
2020-08-30 01:36:17 -04:00
|
|
|
providerKey: req.params.strategy,
|
2019-04-21 21:43:33 -04:00
|
|
|
profile: {
|
|
|
|
...profile,
|
|
|
|
picture: _.get(profile, 'photos[0].value', '')
|
2020-08-30 01:36:17 -04:00
|
|
|
}
|
2019-04-21 21:43:33 -04:00
|
|
|
})
|
|
|
|
cb(null, user)
|
|
|
|
} catch (err) {
|
|
|
|
cb(err, null)
|
|
|
|
}
|
2017-09-10 23:00:03 -04:00
|
|
|
}
|
|
|
|
))
|
|
|
|
}
|
2017-07-29 17:33:08 -04:00
|
|
|
}
|