microsoft.js 819 B

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