Files

13 lines
417 B
TypeScript

import { cookies } from "next/headers";
import { isAuthEnabled } from "@/lib/auth/config";
import { getSessionUsername, SESSION_COOKIE } from "@/lib/auth/session";
export async function getHistoryUsername(): Promise<string | null> {
if (!isAuthEnabled()) {
return "guest";
}
const cookieStore = await cookies();
const token = cookieStore.get(SESSION_COOKIE)?.value;
return getSessionUsername(token);
}