makearmy-app/app/auth/sign-in/page.tsx

26 lines
940 B
TypeScript
Raw Normal View History

2025-09-27 14:30:16 -04:00
// app/auth/sign-in/page.tsx
2025-09-30 13:02:57 -04:00
import { cookies } from "next/headers";
import { redirect } from "next/navigation";
2025-09-27 14:30:16 -04:00
import SignIn from "./sign-in";
2025-09-30 13:02:57 -04:00
export default async function SignInPage(
props: { searchParams: Promise<Record<string, string | string[] | undefined>> }
) {
const sp = await props.searchParams;
2025-09-30 17:04:37 -04:00
2025-09-30 13:02:57 -04:00
const nextParam = Array.isArray(sp.next) ? sp.next[0] : sp.next;
const nextPath = nextParam && nextParam.startsWith("/") ? nextParam : "/portal";
const reauthParam = Array.isArray(sp.reauth) ? sp.reauth[0] : sp.reauth;
const forceParam = Array.isArray(sp.force) ? sp.force[0] : sp.force;
const reauth = reauthParam === "1" || forceParam === "1";
2025-09-30 17:04:37 -04:00
// If reauth is requested, always render the form (no redirect).
if (!reauth) {
const at = (await cookies()).get("ma_at")?.value;
if (at) redirect("/portal");
}
2025-09-30 13:02:57 -04:00
return <SignIn nextPath={nextPath} reauth={reauth} />;
2025-09-26 15:59:15 -04:00
}