🟢 fix: Incorrect customUserVars Set States (#8905)

This commit is contained in:
Dustin Healy 2025-08-06 23:19:06 -07:00 committed by GitHub
parent 0b071c06f6
commit 8530594f37
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 2 deletions

View file

@ -10,15 +10,20 @@ import type {
// Factory function that takes mongoose instance and returns the methods // Factory function that takes mongoose instance and returns the methods
export function createPluginAuthMethods(mongoose: typeof import('mongoose')) { 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({ async function findOnePluginAuth({
userId, userId,
authField, authField,
pluginKey,
}: FindPluginAuthParams): Promise<IPluginAuth | null> { }: FindPluginAuthParams): Promise<IPluginAuth | null> {
try { try {
const PluginAuth: Model<IPluginAuth> = mongoose.models.PluginAuth; 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) { } catch (error) {
throw new Error( throw new Error(
`Failed to find plugin auth: ${error instanceof Error ? error.message : 'Unknown error'}`, `Failed to find plugin auth: ${error instanceof Error ? error.message : 'Unknown error'}`,

View file

@ -18,6 +18,7 @@ export interface PluginAuthQuery {
export interface FindPluginAuthParams { export interface FindPluginAuthParams {
userId: string; userId: string;
authField: string; authField: string;
pluginKey?: string;
} }
export interface FindPluginAuthsByKeysParams { export interface FindPluginAuthsByKeysParams {