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.

33 lines
831 B

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