diff --git a/packages/identity-integration/src/flows/registration.flow.tsx b/packages/identity-integration/src/flows/registration.flow.tsx index 930297d6..d1898244 100644 --- a/packages/identity-integration/src/flows/registration.flow.tsx +++ b/packages/identity-integration/src/flows/registration.flow.tsx @@ -23,12 +23,14 @@ import { handleFlowError } from './handle-errors.util export interface RegistrationFlowProps { onError?: (error: { id: string }) => void returnToUrl?: string + shouldRedirect?: boolean } export const RegistrationFlow: FC> = ({ children, onError, returnToUrl, + shouldRedirect = true, }) => { const [flow, setFlow] = useState() const [identity, setIdentity] = useState() @@ -60,7 +62,7 @@ export const RegistrationFlow: FC> = ({ kratosClient .createBrowserRegistrationFlow( - { returnTo: returnTo?.toString() ?? returnToUrl }, + { returnTo: shouldRedirect ? returnTo?.toString() ?? returnToUrl : undefined }, { withCredentials: true, } @@ -116,7 +118,7 @@ export const RegistrationFlow: FC> = ({ if (flow?.return_to) { window.location.href = flow?.return_to - } else { + } else if (shouldRedirect) { router.push(returnToUrl ?? '/') } })