account auth cleanup

This commit is contained in:
makearmy 2025-09-30 17:04:37 -04:00
parent 6162722c87
commit 94de501a49
5 changed files with 41 additions and 22 deletions

View file

@ -6,10 +6,8 @@ import SignIn from "./sign-in";
export default async function SignInPage(
props: { searchParams: Promise<Record<string, string | string[] | undefined>> }
) {
const at = (await cookies()).get("ma_at")?.value;
if (at) redirect("/portal");
const sp = await props.searchParams;
const nextParam = Array.isArray(sp.next) ? sp.next[0] : sp.next;
const nextPath = nextParam && nextParam.startsWith("/") ? nextParam : "/portal";
@ -17,5 +15,11 @@ export default async function SignInPage(
const forceParam = Array.isArray(sp.force) ? sp.force[0] : sp.force;
const reauth = reauthParam === "1" || forceParam === "1";
// If reauth is requested, always render the form (no redirect).
if (!reauth) {
const at = (await cookies()).get("ma_at")?.value;
if (at) redirect("/portal");
}
return <SignIn nextPath={nextPath} reauth={reauth} />;
}