From e4f6d29a59c9485edaca68f403f4912c3495d773 Mon Sep 17 00:00:00 2001 From: Nikita Elfimov Date: Mon, 4 Dec 2023 13:21:19 +0300 Subject: [PATCH] feat: add new optional prop shouldRedirect to registration flow --- .../identity-integration/src/flows/registration.flow.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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 ?? '/') } })