From cbc6e5068172890ddf8c669f566385a80039d703 Mon Sep 17 00:00:00 2001 From: TomDakan Date: Mon, 25 Sep 2023 15:02:26 -0700 Subject: [PATCH] Move initialization of DiscordOauth2 outside of passport strategy initialization --- server/modules/authentication/discord/authentication.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/modules/authentication/discord/authentication.js b/server/modules/authentication/discord/authentication.js index 3c0af63a..1a090199 100644 --- a/server/modules/authentication/discord/authentication.js +++ b/server/modules/authentication/discord/authentication.js @@ -21,6 +21,7 @@ function hasRoles(memberRoles, authRoles) { module.exports = { init (passport, conf) { + const discord = new DiscordOauth2() passport.use(conf.key, new DiscordStrategy({ clientID: conf.clientId, @@ -32,7 +33,6 @@ module.exports = { }, async (req, accessToken, refreshToken, profile, cb) => { try { if (conf.roles) { - const discord = new DiscordOauth2() const memberRoles = await discord.getGuildMember(accessToken, conf.guildId) const authRoles = conf.roles.split(); const { roles } = await discord.getGuildMember(accessToken, conf.guildId);