MCPcopy
hub / github.com/simstudioai/sim / disableUserResources

Function disableUserResources

apps/sim/lib/workflows/lifecycle.ts:351–370  ·  view source on GitHub ↗
(userId: string)

Source from the content-addressed store, hash-verified

349 * and deleting their personal API keys.
350 */
351export async function disableUserResources(userId: string): Promise<void> {
352 const requestId = generateRequestId()
353 logger.info(`[${requestId}] Disabling resources for banned user ${userId}`)
354
355 const { archiveWorkspace } = await import('@/lib/workspaces/lifecycle')
356
357 const ownedWorkspaces = await db
358 .select({ id: workspace.id })
359 .from(workspace)
360 .where(and(eq(workspace.ownerId, userId), isNull(workspace.archivedAt)))
361
362 await Promise.all([
363 ...ownedWorkspaces.map((w) => archiveWorkspace(w.id, { requestId })),
364 db.delete(apiKey).where(eq(apiKey.userId, userId)),
365 ])
366
367 logger.info(
368 `[${requestId}] Disabled resources for user ${userId}: archived ${ownedWorkspaces.length} workspaces, deleted API keys`
369 )
370}

Callers 1

auth.tsFile · 0.90

Calls 5

generateRequestIdFunction · 0.90
archiveWorkspaceFunction · 0.85
infoMethod · 0.80
deleteMethod · 0.65
eqFunction · 0.50

Tested by

no test coverage detected