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

Function getAuthorizedSuperUserId

apps/sim/app/api/copilot/byok/route.ts:30–43  ·  view source on GitHub ↗

* Enterprise BYOK key management for the current workspace's mothership. * * Unlike the cross-environment admin inspector (`/api/admin/mothership`), this * talks to the SAME copilot the workspace's mothership actually runs on — * `SIM_AGENT_API_URL` (local in dev, prod copilot in prod) — and aut

()

Source from the content-addressed store, hash-verified

28 * request and is resolved by the caller from the route.
29 */
30async function getAuthorizedSuperUserId(): Promise<string | null> {
31 const session = await getSession()
32 if (!session?.user?.id) return null
33
34 const [currentUser] = await db
35 .select({ role: user.role, superUserModeEnabled: settings.superUserModeEnabled })
36 .from(user)
37 .leftJoin(settings, eq(settings.userId, user.id))
38 .where(eq(user.id, session.user.id))
39 .limit(1)
40
41 const authorized = currentUser?.role === 'admin' && (currentUser.superUserModeEnabled ?? false)
42 return authorized ? session.user.id : null
43}
44
45async function forwardToCopilot(
46 method: 'GET' | 'POST' | 'DELETE',

Callers 1

route.tsFile · 0.85

Calls 1

eqFunction · 0.50

Tested by

no test coverage detected