MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / getUserIdFromSessionToken

Function getUserIdFromSessionToken

web/src/util/auth.ts:11–22  ·  view source on GitHub ↗
(
  sessionToken: string,
)

Source from the content-addressed store, hash-verified

9 * Returns null if the token is invalid or expired.
10 */
11export async function getUserIdFromSessionToken(
12 sessionToken: string,
13): Promise<string | null> {
14 const session = await db.query.session.findFirst({
15 where: and(
16 eq(schema.session.sessionToken, sessionToken),
17 gt(schema.session.expires, new Date()),
18 ),
19 columns: { userId: true },
20 })
21 return session?.userId ?? null
22}
23
24/**
25 * Extract api key from x-codebuff-api-key header or authorization header

Callers 3

PATCHFunction · 0.90
GETFunction · 0.90
GETFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected