Files
IPFS-portal/src/app/api/auth/me/route.ts
T

32 lines
813 B
TypeScript
Raw Normal View History

/* ── GET /api/auth/me ──
*
* Checkt huidige sessie op basis van httpOnly cookie.
* Geeft wallet address en role terug.
*/
import { cookies } from 'next/headers';
import { NextResponse } from 'next/server';
import { verifySessionJWT, SESSION_COOKIE } from '@/lib/auth-server';
export const dynamic = 'force-dynamic';
export async function GET() {
const cookieStore = await cookies();
const token = cookieStore.get(SESSION_COOKIE)?.value;
if (!token) {
return NextResponse.json({ authenticated: false }, { status: 401 });
}
const session = await verifySessionJWT(token);
if (!session) {
return NextResponse.json({ authenticated: false }, { status: 401 });
}
return NextResponse.json({
authenticated: true,
address: session.address,
role: session.role,
});
}