fixed issue with login page.

This commit is contained in:
bobbert committed 2025-03-14 23:50:25 +00:00
1 parent 11fc5c8b3d
commit 84f010cb87
6 files changed
+153 -30

No files matched your search

+55
View File
@@ -0,0 +1,55 @@
import { getServerSession } from "next-auth/next";
import { authOptions } from "../[...nextauth]/route";
export async function GET(req) {
try {
const session = await getServerSession(authOptions);
if (!session) {
return new Response(
JSON.stringify({
authenticated: false,
message: "Not authenticated",
}),
{
status: 401,
headers: {
"Content-Type": "application/json",
},
}
);
}
return new Response(
JSON.stringify({
authenticated: true,
user: {
id: session.user.id,
username: session.user.username,
role: session.user.role,
teamId: session.user.teamId,
},
}),
{
status: 200,
headers: {
"Content-Type": "application/json",
},
}
);
} catch (error) {
console.error("Session check error:", error);
return new Response(
JSON.stringify({
error: "Internal server error checking authentication",
}),
{
status: 500,
headers: {
"Content-Type": "application/json",
},
}
);
}
}