mirror of
https://github.com/mudabbir-ahmad/peworkshop.git
synced 2026-10-08 03:50:21 +00:00
27 lines
788 B
JavaScript
27 lines
788 B
JavaScript
import { redirect } from "next/navigation";
|
|
import { cookies } from "next/headers";
|
|
import { verifyToken } from "@/app/api/auth/[...nextauth]/route";
|
|
|
|
export async function GET(_, context) {
|
|
try {
|
|
// Use our custom token verification instead of getServerSession
|
|
const cookieStore = await cookies();
|
|
const sessionToken = cookieStore.get("next-auth.session-token")?.value;
|
|
|
|
if (!sessionToken) {
|
|
return redirect("/login");
|
|
}
|
|
|
|
const userData = verifyToken(sessionToken);
|
|
if (!userData) {
|
|
return redirect("/login");
|
|
}
|
|
|
|
// Instead of returning JSON, redirect to the page component
|
|
return redirect(`/${context.params.teamId}`);
|
|
} catch (error) {
|
|
console.error("Team route error:", error);
|
|
return redirect("/team-selection");
|
|
}
|
|
}
|