c9432a16ba
- SIWE auth flow: challenge/login/logout/me API routes + JWT middleware
- Fixed [...path] catch-all: Kubo proxy with matchRoute() + mapToKuboAPI()
- Fixed session_id → nonce field mismatch in AuthProvider
- Fixed dashboard pins crash: Kubo returns {Keys: {...}}, not array
- Added middleware route guard (307 redirect to /login)
- Added login, register, profile, usage, upload pages
- Added dashboard components (StorageGauge, FreeTierProgress)
- Added SWR hooks + AuthGuard + Providers + Toast/ErrorBoundary
- Added payment integration (smart contract ABI, tiers, tokens)
- Fixed IPNS key listing: Name/Id → name/id mapping
- Added PWA support (manifest, service worker, icons)
- Added tests for helpers, limits, search-index, wallet
32 lines
813 B
TypeScript
32 lines
813 B
TypeScript
/* ── 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,
|
|
});
|
|
}
|