From bb5ff672509f5bd11651ed7ce2fa0336454c341a Mon Sep 17 00:00:00 2001 From: alma Date: Fri, 16 Jan 2026 23:20:58 +0100 Subject: [PATCH] Fondation --- app/api/courrier/account/route.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/api/courrier/account/route.ts b/app/api/courrier/account/route.ts index 27a9130..54d5c6c 100644 --- a/app/api/courrier/account/route.ts +++ b/app/api/courrier/account/route.ts @@ -264,11 +264,13 @@ export async function POST(request: Request) { } export async function DELETE(request: Request) { + // Authenticate user (declare outside try to access in catch) + const session = await getServerSession(authOptions); + if (!session?.user?.id) { + return NextResponse.json({ error: 'Unauthorized' }, { status: 401 }); + } + try { - const session = await getServerSession(authOptions); - if (!session?.user?.id) { - return NextResponse.json({ error: 'Unauthorized' }, { status: 401 }); - } const { searchParams } = new URL(request.url); const accountId = searchParams.get('accountId'); if (!accountId) {