MCPcopy Index your code
hub / github.com/simstudioai/sim / getCredentialByAccountId

Function getCredentialByAccountId

apps/sim/app/api/auth/oauth/utils.ts:298–314  ·  view source on GitHub ↗

* Get a credential by resolved account ID and verify it belongs to the user.

(requestId: string, accountId: string, userId: string)

Source from the content-addressed store, hash-verified

296 * Get a credential by resolved account ID and verify it belongs to the user.
297 */
298async function getCredentialByAccountId(requestId: string, accountId: string, userId: string) {
299 const credentials = await db
300 .select()
301 .from(account)
302 .where(and(eq(account.id, accountId), eq(account.userId, userId)))
303 .limit(1)
304
305 if (!credentials.length) {
306 logger.warn(`[${requestId}] Credential not found`)
307 return undefined
308 }
309
310 return {
311 ...credentials[0],
312 resolvedCredentialId: accountId,
313 }
314}
315
316/**
317 * Get a credential by ID and verify it belongs to the user.

Callers 2

getCredentialFunction · 0.85

Calls 2

warnMethod · 0.65
eqFunction · 0.50

Tested by

no test coverage detected