🟢 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
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'}`,

View file

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