Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

fix(discordStrategy): only authorize on first login (#626)

Marco Beretta981d0095084b
diff --git a/api/strategies/discordStrategy.js b/api/strategies/discordStrategy.js
index 428279ebfb..040453d9cd 100644
--- a/api/strategies/discordStrategy.js
+++ b/api/strategies/discordStrategy.js
@@ -9,23 +9,17 @@ const discordLogin = new DiscordStrategy(
clientID: process.env.DISCORD_CLIENT_ID,
clientSecret: process.env.DISCORD_CLIENT_SECRET,
callbackURL: `${domains.server}${process.env.DISCORD_CALLBACK_URL}`,
- scope: ['identify', 'email'] // Request scopes
+ scope: ['identify', 'email'], // Request scopes
+ authorizationURL: 'https://discord.com/api/oauth2/authorize?prompt=none' // Add the prompt query parameter
},
async (accessToken, refreshToken, profile, cb) => {
try {
- const discordId = profile.id;
const email = profile.email;
+ const discordId = profile.id;
- const existingUser = await User.findOne({ discordId });
- if (existingUser) {
- return cb(null, existingUser);
- }
-
- const userWithEmail = await User.findOne({ email });
- if (userWithEmail) {
- userWithEmail.discordId = discordId;
- await userWithEmail.save();
- return cb(null, userWithEmail);
+ const oldUser = await User.findOne({ email });
+ if (oldUser) {
+ return cb(null, oldUser);
}
let avatarURL;