tonestrike / passport-discord

ISC License
2 stars 3 forks source link

Failed to fetch user's guilds #3

Open TurtIeSocks opened 3 years ago

TurtIeSocks commented 3 years ago

Just saw your fork last night and noticed it said it fixed this issue that pops up if a user clicks authorize more than once.

I don't have a ton of experience with Discord oauth and Passport but I'm still seeing this error even if I comment out the rest of my Discord auth function (authHandler in this case). The basis of my Discord strategy for reference:

passport.use(new DiscordStrategy({
  clientID: config.discord.clientId,
  clientSecret: config.discord.clientSecret,
  callbackURL: config.discord.redirectUri,
  scope: ['identify', 'guilds', 'email'],
  passReqToCallback: true,
}, authHandler))

Snippet of authHandler:

 await User.query()
    .findOne({ id: profile.id })
    .then(async (userExists) => {
      if (!userExists) {
        await User.query()
          .insert({ id: profile.id })
        return done(null, profile)
      }
      return done(null, profile)
    })

There's more to it but I can still reproduce the error even if it's all commented out so I don't think it's relevant. Sorry if I missed something obvious that I'm supposed to be doing differently compared to the main repo.

This also happens to be my first time using a fork of a package, so I should probably verify with you that I'm doing this correctly in my package.json: "passport-discord": "https://github.com/tonestrike/passport-discord.git",

Let me know if you need any additional info, thanks!