From 85487b2fb107e394d5cefe4725eb0cac99d37bad Mon Sep 17 00:00:00 2001 From: bender Date: Wed, 10 Jun 2026 15:40:43 +0000 Subject: [PATCH] Add src/app/api/admin/check-auth/route.ts --- src/app/api/admin/check-auth/route.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/app/api/admin/check-auth/route.ts diff --git a/src/app/api/admin/check-auth/route.ts b/src/app/api/admin/check-auth/route.ts new file mode 100644 index 0000000..b241705 --- /dev/null +++ b/src/app/api/admin/check-auth/route.ts @@ -0,0 +1,14 @@ +import { NextRequest, NextResponse } from 'next/server'; + +export async function GET(req: NextRequest) { + // In a real app, this would verify the JWT token from headers or session cookie. + // For this mock, we assume the middleware handled the primary check, + // or a client component sends a token to be verified. + const token = req.cookies.get('adminToken')?.value || req.headers.get('Authorization')?.split(' ')[1]; + + if (token === 'mock-admin-token') { + return NextResponse.json({ isAuthenticated: true, role: 'admin' }, { status: 200 }); + } else { + return NextResponse.json({ isAuthenticated: false }, { status: 401 }); + } +} \ No newline at end of file