Add src/app/api/admin/check-auth/route.ts
This commit is contained in:
14
src/app/api/admin/check-auth/route.ts
Normal file
14
src/app/api/admin/check-auth/route.ts
Normal file
@@ -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 });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user