29 lines
636 B
TypeScript
29 lines
636 B
TypeScript
import { NextResponse } from "next/server";
|
|
import { auth } from "@/app/(auth)/auth";
|
|
|
|
export async function GET() {
|
|
const session = await auth().catch(() => null);
|
|
const user = session?.user
|
|
? {
|
|
id: session.user.id,
|
|
email: session.user.email ?? null,
|
|
name: session.user.name ?? null,
|
|
image: session.user.image ?? null,
|
|
type: session.user.type ?? null,
|
|
}
|
|
: null;
|
|
|
|
return NextResponse.json(
|
|
{
|
|
valid: Boolean(user?.id),
|
|
user,
|
|
userType: user?.type ?? null,
|
|
},
|
|
{
|
|
headers: {
|
|
"Cache-Control": "no-store, max-age=0",
|
|
},
|
|
}
|
|
);
|
|
}
|