slack.js 772 B

123456789101112131415161718192021222324252627
  1. 'use strict'
  2. /* global wiki */
  3. // ------------------------------------
  4. // Slack Account
  5. // ------------------------------------
  6. const SlackStrategy = require('passport-slack').Strategy
  7. module.exports = (passport) => {
  8. if (wiki.config.auth.slack && wiki.config.auth.slack.enabled) {
  9. passport.use('slack',
  10. new SlackStrategy({
  11. clientID: wiki.config.auth.slack.clientId,
  12. clientSecret: wiki.config.auth.slack.clientSecret,
  13. callbackURL: wiki.config.host + '/login/slack/callback'
  14. }, (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. }