mirror of
https://github.com/fosrl/pangolin.git
synced 2026-02-08 05:56:38 +00:00
24 lines
625 B
TypeScript
24 lines
625 B
TypeScript
import { internal } from "@app/api";
|
|
import { GetUserResponse } from "@server/routers/user";
|
|
import { AxiosResponse } from "axios";
|
|
import { cookies } from "next/headers";
|
|
|
|
export async function verifySession(): Promise<GetUserResponse | null> {
|
|
const sessionId = cookies().get("session")?.value ?? null;
|
|
|
|
try {
|
|
const res = await internal.get<AxiosResponse<GetUserResponse>>(
|
|
"/user",
|
|
{
|
|
headers: {
|
|
Cookie: `session=${sessionId}`,
|
|
},
|
|
},
|
|
);
|
|
|
|
return res.data.data;
|
|
} catch {
|
|
return null;
|
|
}
|
|
}
|