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: Incorrect `customUserVars` Set States (#8905)

Dustin Healy8530594f3712
diff --git a/packages/data-schemas/src/methods/pluginAuth.ts b/packages/data-schemas/src/methods/pluginAuth.ts
index 5355fec50c..9f79552a80 100644
--- a/packages/data-schemas/src/methods/pluginAuth.ts
+++ b/packages/data-schemas/src/methods/pluginAuth.ts
@@ -10,15 +10,20 @@ import type {
// Factory function that takes mongoose instance and returns the methods
export function createPluginAuthMethods(mongoose: typeof import('mongoose')) {
/**
- * Finds a single plugin auth entry by userId and authField
+ * Finds a single plugin auth entry by userId and authField (and optionally pluginKey)
*/
async function findOnePluginAuth({
userId,
authField,
+ pluginKey,
}: FindPluginAuthParams): Promise<IPluginAuth | null> {
try {
const PluginAuth: Model<IPluginAuth> = mongoose.models.PluginAuth;
- return await PluginAuth.findOne({ userId, authField }).lean();
+ return await PluginAuth.findOne({
+ userId,
+ authField,
+ ...(pluginKey && { pluginKey }),
+ }).lean();
} catch (error) {
throw new Error(
`Failed to find plugin auth: ${error instanceof Error ? error.message : 'Unknown error'}`,
diff --git a/packages/data-schemas/src/types/pluginAuth.ts b/packages/data-schemas/src/types/pluginAuth.ts
index 421769eaa3..c38bc790ab 100644
--- a/packages/data-schemas/src/types/pluginAuth.ts
+++ b/packages/data-schemas/src/types/pluginAuth.ts
@@ -18,6 +18,7 @@ export interface PluginAuthQuery {
export interface FindPluginAuthParams {
userId: string;
authField: string;
+ pluginKey?: string;
}
export interface FindPluginAuthsByKeysParams {