fix: validate session for signup wizard steps (Task 5)

This commit is contained in:
2026-05-27 02:50:00 +08:00
parent 079df570c5
commit 5db12dfe1c
2 changed files with 111 additions and 1 deletions
+9 -1
View File
@@ -26,7 +26,15 @@ export async function proxy(req: NextRequest) {
if (path === "/signup") {
const step = req.nextUrl.searchParams.get("step")
if (step === "otp" || step === "passkey") {
return NextResponse.next()
// Wizard step URLs require a valid session (created by signUp.email() in step 1).
// Without a session, redirect to /signup to prevent URL-guessing bypass.
const wizardSession = await auth.api.getSession({
headers: req.headers,
})
if (wizardSession) {
return NextResponse.next()
}
return NextResponse.redirect(new URL("/signup", req.url))
}
}