Route landing account sign-ins to checkout

This commit is contained in:
2569718930@qq.com
2026-06-14 03:14:10 +08:00
parent 8e775e0429
commit 5d0f2d4505
7 changed files with 38 additions and 14 deletions
+5 -5
View File
@@ -51,13 +51,13 @@ async function resolvePostLoginRedirect({
Authorization: `Bearer ${token}`,
},
});
if (!response.ok) return nextPath;
if (!response.ok) return TERMINAL_CHECKOUT_PATH;
const payload = await response.json();
return payload?.subscription_active === false
? TERMINAL_CHECKOUT_PATH
: nextPath;
return payload?.subscription_active === true
? nextPath
: TERMINAL_CHECKOUT_PATH;
} catch {
return nextPath;
return TERMINAL_CHECKOUT_PATH;
}
}
@@ -20,19 +20,22 @@ export function runTests() {
loginClientSource.includes("TERMINAL_CHECKOUT_PATH") &&
loginClientSource.includes('"/account?checkout=1"') &&
loginClientSource.includes("resolvePostLoginRedirect") &&
loginClientSource.includes("subscription_active === false") &&
loginClientSource.includes("subscription_active === true") &&
loginClientSource.includes("return TERMINAL_CHECKOUT_PATH") &&
loginClientSource.includes("router.replace(redirectPath)") &&
!loginClientSource.includes("if (!response.ok) return nextPath;") &&
!loginClientSource.includes("catch {\n return nextPath;") &&
!loginClientSource.includes("router.replace(nextPath);\n return;"),
"email/password terminal login must send non-members to the checkout account page instead of blindly returning to /terminal",
"email/password terminal login must only enter /terminal after confirmed active subscription; unknown or inactive users go to checkout",
);
assert(
authCallbackSource.includes("resolvePostAuthRedirect") &&
authCallbackSource.includes("TERMINAL_CHECKOUT_PATH") &&
authCallbackSource.includes('"/account?checkout=1"') &&
authCallbackSource.includes("subscription_active === false") &&
authCallbackSource.includes("subscription_active === true") &&
authCallbackSource.includes("NextResponse.redirect(redirectUrl)") &&
authCallbackSource.includes("await resolvePostAuthRedirect"),
"OAuth terminal callback must send non-members to the checkout account page instead of blindly returning to /terminal",
"OAuth terminal callback must only enter /terminal after confirmed active subscription; unknown or inactive users go to checkout",
);
}