Fix auth login redirect loop

This commit is contained in:
2569718930@qq.com
2026-06-14 02:20:20 +08:00
parent f071ac504d
commit 00da22e594
2 changed files with 28 additions and 14 deletions
@@ -0,0 +1,28 @@
import fs from "node:fs";
import path from "node:path";
function assert(condition: unknown, message: string) {
if (!condition) throw new Error(message);
}
export function runTests() {
const source = fs.readFileSync(
path.join(process.cwd(), "components", "auth", "LoginClient.tsx"),
"utf8",
).replace(/\r\n/g, "\n");
const start = source.indexOf("const onResetPassword");
const end = source.indexOf("const onGoogleSignIn");
assert(
start >= 0 && end > start,
"login page pre-submit auth initialization block must be detectable by this regression test",
);
const loginMountEffect = source.slice(start, end);
assert(
!loginMountEffect.includes("router.replace(nextPath)"),
"login page must not auto-return to nextPath from a cached Supabase session before the user submits auth",
);
}