MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / createSession

Function createSession

packages/auth/src/session.ts:16–32  ·  view source on GitHub ↗
(
  token: string,
  userId: string
)

Source from the content-addressed store, hash-verified

14}
15
16export async function createSession(
17 token: string,
18 userId: string
19): Promise<Session> {
20 const sessionId = encodeHexLowerCase(sha256(new TextEncoder().encode(token)));
21 const session: Session = {
22 id: sessionId,
23 userId,
24 expiresAt: new Date(Date.now() + 1000 * 60 * 60 * 24 * 30),
25 createdAt: new Date(),
26 updatedAt: new Date(),
27 };
28 await db.session.create({
29 data: session,
30 });
31 return session;
32}
33
34export const EMPTY_SESSION: SessionValidationResult = {
35 session: null,

Callers 3

auth.tsFile · 0.90
handleExistingUserFunction · 0.90
handleNewUserFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected