MCPcopy Create free account
hub / github.com/R44VC0RP/opencode.cafe / checkIsAdmin

Function checkIsAdmin

convex/admin.ts:6–14  ·  view source on GitHub ↗
(ctx: QueryCtx | MutationCtx)

Source from the content-addressed store, hash-verified

4
5// Helper to check if user is admin based on Clerk metadata
6async function checkIsAdmin(ctx: QueryCtx | MutationCtx): Promise<boolean> {
7 const identity = await ctx.auth.getUserIdentity()
8 if (!identity) return false
9
10 // Check for admin role in Clerk public metadata (snake_case from JWT)
11 // eslint-disable-next-line @typescript-eslint/no-explicit-any
12 const metadata = (identity as any).public_metadata as { role?: string } | undefined
13 return metadata?.role === "admin"
14}
15
16// Query to check if current user is admin (for UI)
17export const isAdmin = query({

Callers 1

admin.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected