Guard checkout payment step behind login
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (push) Has been cancelled
tests / ui (push) Has been cancelled

This commit is contained in:
Codex Agent
2026-01-04 12:43:04 +01:00
parent 1afd49bd24
commit cbb010acca
5 changed files with 56 additions and 1 deletions

View File

@@ -191,6 +191,8 @@ export const PaymentStep: React.FC = () => {
nextStep,
paddleConfig,
authUser,
isAuthenticated,
goToStep,
setPaymentCompleted,
checkoutSessionId,
setCheckoutSessionId,
@@ -368,6 +370,13 @@ export const PaymentStep: React.FC = () => {
}, [couponCode]);
const handleFreeActivation = async () => {
if (!isAuthenticated || !authUser) {
const message = t('checkout.payment_step.auth_required');
toast.error(message);
goToStep('auth');
return;
}
if (!selectedPackage) {
return;
}
@@ -420,6 +429,15 @@ export const PaymentStep: React.FC = () => {
return;
}
if (!isAuthenticated || !authUser) {
const message = t('checkout.payment_step.auth_required');
setStatus('error');
setMessage(message);
toast.error(message);
goToStep('auth');
return;
}
if (!acceptedTerms) {
setConsentError(t('checkout.legal.checkbox_terms_error'));
return;
@@ -466,6 +484,18 @@ export const PaymentStep: React.FC = () => {
});
const rawBody = await response.text();
if (
response.status === 401 ||
response.status === 419 ||
(response.redirected && response.url.includes('/login'))
) {
const message = t('checkout.payment_step.auth_required');
setStatus('error');
setMessage(message);
toast.error(message);
goToStep('auth');
return;
}
if (typeof window !== 'undefined') {
console.info('[Checkout] Hosted checkout response', { status: response.status, rawBody });