feat: Implement safe redirect handling in CompleteAccountStep and SuccessStep components
This commit is contained in:
parent
5c6bd00346
commit
04fd0ea233
@ -16,6 +16,7 @@ import {
|
|||||||
type JapanAddressFormData,
|
type JapanAddressFormData,
|
||||||
} from "@/features/address/components/JapanAddressForm";
|
} from "@/features/address/components/JapanAddressForm";
|
||||||
import { prepareWhmcsAddressFields } from "@customer-portal/domain/address";
|
import { prepareWhmcsAddressFields } from "@customer-portal/domain/address";
|
||||||
|
import { getSafeRedirect } from "@/features/auth/utils/route-protection";
|
||||||
import { useGetStartedStore } from "../../../stores/get-started.store";
|
import { useGetStartedStore } from "../../../stores/get-started.store";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
|
|
||||||
@ -47,8 +48,11 @@ export function CompleteAccountStep() {
|
|||||||
serviceContext,
|
serviceContext,
|
||||||
} = useGetStartedStore();
|
} = useGetStartedStore();
|
||||||
|
|
||||||
// Compute effective redirect URL from store state
|
// Compute effective redirect URL from store state (with validation)
|
||||||
const effectiveRedirectTo = redirectTo || serviceContext?.redirectTo || "/account/dashboard";
|
const effectiveRedirectTo = getSafeRedirect(
|
||||||
|
redirectTo || serviceContext?.redirectTo,
|
||||||
|
"/account/dashboard"
|
||||||
|
);
|
||||||
|
|
||||||
// Check if this is a new customer (needs full form) or SF-only (has prefill)
|
// Check if this is a new customer (needs full form) or SF-only (has prefill)
|
||||||
const isNewCustomer = accountStatus === "new_customer";
|
const isNewCustomer = accountStatus === "new_customer";
|
||||||
|
|||||||
@ -6,13 +6,17 @@
|
|||||||
|
|
||||||
import { Button } from "@/components/atoms";
|
import { Button } from "@/components/atoms";
|
||||||
import { CheckCircleIcon, ArrowRightIcon } from "@heroicons/react/24/outline";
|
import { CheckCircleIcon, ArrowRightIcon } from "@heroicons/react/24/outline";
|
||||||
|
import { getSafeRedirect } from "@/features/auth/utils/route-protection";
|
||||||
import { useGetStartedStore } from "../../../stores/get-started.store";
|
import { useGetStartedStore } from "../../../stores/get-started.store";
|
||||||
|
|
||||||
export function SuccessStep() {
|
export function SuccessStep() {
|
||||||
const { redirectTo, serviceContext } = useGetStartedStore();
|
const { redirectTo, serviceContext } = useGetStartedStore();
|
||||||
|
|
||||||
// Compute effective redirect URL from store state
|
// Compute effective redirect URL from store state (with validation)
|
||||||
const effectiveRedirectTo = redirectTo || serviceContext?.redirectTo || "/account/dashboard";
|
const effectiveRedirectTo = getSafeRedirect(
|
||||||
|
redirectTo || serviceContext?.redirectTo,
|
||||||
|
"/account/dashboard"
|
||||||
|
);
|
||||||
|
|
||||||
// Determine if redirecting to dashboard (default) or a specific service
|
// Determine if redirecting to dashboard (default) or a specific service
|
||||||
const isDefaultRedirect = effectiveRedirectTo === "/account/dashboard";
|
const isDefaultRedirect = effectiveRedirectTo === "/account/dashboard";
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user