37 lines
860 B
TypeScript
37 lines
860 B
TypeScript
import { NextRequest, NextResponse } from "next/server";
|
|
|
|
export async function GET(request: NextRequest) {
|
|
try {
|
|
const authHeader = request.headers.get("authorization");
|
|
|
|
if (!authHeader || !authHeader.startsWith("Bearer ")) {
|
|
return NextResponse.json(
|
|
{ message: "Token não fornecido" },
|
|
{ status: 401 }
|
|
);
|
|
}
|
|
|
|
const token = authHeader.substring(7);
|
|
|
|
// Validate token (in production, verify JWT signature)
|
|
if (token.length !== 64) {
|
|
return NextResponse.json(
|
|
{ message: "Token inválido" },
|
|
{ status: 401 }
|
|
);
|
|
}
|
|
|
|
return NextResponse.json(
|
|
{
|
|
valid: true,
|
|
message: "Sessão válida"},
|
|
{ status: 200 }
|
|
);
|
|
} catch (error) {
|
|
return NextResponse.json(
|
|
{ message: "Erro ao verificar sessão" },
|
|
{ status: 500 }
|
|
);
|
|
}
|
|
}
|