MCPcopy
hub / github.com/Snouzy/workout-cool / getMobileCompatibleSession

Function getMobileCompatibleSession

src/shared/api/mobile-auth.ts:24–45  ·  view source on GitHub ↗
(req: NextRequest)

Source from the content-addressed store, hash-verified

22 * ```
23 */
24export async function getMobileCompatibleSession(req: NextRequest) {
25 const rawCookieHeader = req.headers.get("cookie");
26
27 // If no cookies, no session
28 if (!rawCookieHeader) {
29 return null;
30 }
31
32 // Clean the cookies
33 const cleanedCookieHeader = cleanMobileCookies(rawCookieHeader);
34
35 // Create new headers with cleaned cookies
36 const cleanHeaders = new Headers(req.headers);
37 cleanHeaders.set("cookie", cleanedCookieHeader);
38
39 // Get session with cleaned headers
40 const session = await auth.api.getSession({
41 headers: cleanHeaders,
42 });
43
44 return session;
45}
46
47/**
48 * Type guard to check if a session has a valid user

Callers 15

GETFunction · 0.90
DELETEFunction · 0.90
POSTFunction · 0.90
GETFunction · 0.90
POSTFunction · 0.90
POSTFunction · 0.90
PUTFunction · 0.90
GETFunction · 0.90
PUTFunction · 0.90
GETFunction · 0.90
GETFunction · 0.90
GETFunction · 0.90

Calls 1

cleanMobileCookiesFunction · 0.90

Tested by

no test coverage detected