twitch.js 799 Bytes
Newer Older
1
/* global WIKI */
2 3 4 5 6 7 8 9 10 11 12

// ------------------------------------
// Twitch Account
// ------------------------------------

const TwitchStrategy = require('passport-twitch').Strategy

module.exports = {
  key: 'twitch',
  title: 'Twitch',
  useForm: false,
13 14 15 16
  props: {
    clientId: String,
    clientSecret: String
  },
17 18 19 20 21 22 23 24
  init (passport, conf) {
    passport.use('twitch',
      new TwitchStrategy({
        clientID: conf.clientId,
        clientSecret: conf.clientSecret,
        callbackURL: conf.callbackURL,
        scope: 'user_read'
      }, function (accessToken, refreshToken, profile, cb) {
25
        WIKI.db.users.processProfile(profile).then((user) => {
26 27 28 29 30 31 32 33
          return cb(null, user) || true
        }).catch((err) => {
          return cb(err, null) || true
        })
      }
      ))
  }
}