discord.js 811 B

123456789101112131415161718192021222324252627282930313233
  1. /* global WIKI */
  2. // ------------------------------------
  3. // Discord Account
  4. // ------------------------------------
  5. const DiscordStrategy = require('passport-discord').Strategy
  6. module.exports = {
  7. key: 'discord',
  8. title: 'Discord',
  9. useForm: false,
  10. props: {
  11. clientId: String,
  12. clientSecret: String
  13. },
  14. init (passport, conf) {
  15. passport.use('discord',
  16. new DiscordStrategy({
  17. clientID: conf.clientId,
  18. clientSecret: conf.clientSecret,
  19. callbackURL: conf.callbackURL,
  20. scope: 'identify email'
  21. }, function (accessToken, refreshToken, profile, cb) {
  22. WIKI.db.users.processProfile(profile).then((user) => {
  23. return cb(null, user) || true
  24. }).catch((err) => {
  25. return cb(err, null) || true
  26. })
  27. }
  28. ))
  29. }
  30. }