You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
732 B

  1. /* global WIKI */
  2. // ------------------------------------
  3. // OAuth2 Account
  4. // ------------------------------------
  5. const OAuth2Strategy = require('passport-oauth2').Strategy
  6. module.exports = {
  7. init (passport, conf) {
  8. passport.use('oauth2',
  9. new OAuth2Strategy({
  10. authorizationURL: conf.authorizationURL,
  11. tokenURL: conf.tokenURL,
  12. clientID: conf.clientId,
  13. clientSecret: conf.clientSecret,
  14. callbackURL: conf.callbackURL
  15. }, (accessToken, refreshToken, profile, cb) => {
  16. WIKI.models.users.processProfile(profile).then((user) => {
  17. return cb(null, user) || true
  18. }).catch((err) => {
  19. return cb(err, null) || true
  20. })
  21. })
  22. )
  23. }
  24. }