authentication.js 860 B

123456789101112131415161718192021222324252627282930313233
  1. /* global WIKI */
  2. // ------------------------------------
  3. // Microsoft Account
  4. // ------------------------------------
  5. const WindowsLiveStrategy = require('passport-windowslive').Strategy
  6. module.exports = {
  7. init (passport, conf) {
  8. passport.use('microsoft',
  9. new WindowsLiveStrategy({
  10. clientID: conf.clientId,
  11. clientSecret: conf.clientSecret,
  12. callbackURL: conf.callbackURL
  13. }, async (accessToken, refreshToken, profile, cb) => {
  14. console.info(profile)
  15. try {
  16. const user = await WIKI.models.users.processProfile({
  17. profile: {
  18. ...profile,
  19. picture: _.get(profile, 'photos[0].value', '')
  20. },
  21. providerKey: 'microsoft'
  22. })
  23. cb(null, user)
  24. } catch (err) {
  25. cb(err, null)
  26. }
  27. }
  28. ))
  29. }
  30. }