import { getSession } from "@/actions/oauth"; import { isRedirectError } from "next/dist/client/components/redirect-error"; import { redirect } from "next/navigation"; export default async function OAuthPage({ searchParams, }: { searchParams: Promise<{ [key: string]: string | string[] | undefined }>; }) { try { const session = (await searchParams).session as string | undefined; if (!session) redirect("/oauth/error"); const data = await getSession(session); if (!data) redirect("/oauth/error"); const isAuthenticated = data.user_id && data.user_id !== "00000000-0000-0000-0000-000000000000"; redirect(isAuthenticated ? `/consent?session=${session}` : `/login?session=${session}`); } catch (error) { if (isRedirectError(error)) throw error; console.error("OAuth page error:", error); redirect("/oauth/error"); } }