Route landing account sign-ins to checkout
This commit is contained in:
@@ -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",
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user