diff --git a/.yarn/cache/@next-swc-darwin-arm64-npm-14.1.0-6d433a23a7-10.zip b/.yarn/cache/@next-swc-linux-x64-gnu-npm-14.1.0-5a9ae6f5df-10.zip similarity index 70% rename from .yarn/cache/@next-swc-darwin-arm64-npm-14.1.0-6d433a23a7-10.zip rename to .yarn/cache/@next-swc-linux-x64-gnu-npm-14.1.0-5a9ae6f5df-10.zip index 0cce729f..171ce968 100644 Binary files a/.yarn/cache/@next-swc-darwin-arm64-npm-14.1.0-6d433a23a7-10.zip and b/.yarn/cache/@next-swc-linux-x64-gnu-npm-14.1.0-5a9ae6f5df-10.zip differ diff --git a/.yarn/cache/fsevents-patch-6b67494872-10.zip b/.yarn/cache/fsevents-patch-6b67494872-10.zip deleted file mode 100644 index 9887ada7..00000000 Binary files a/.yarn/cache/fsevents-patch-6b67494872-10.zip and /dev/null differ diff --git a/packages/identity-integration/src/flows/registration.flow.tsx b/packages/identity-integration/src/flows/registration.flow.tsx index f302cc4c..8afc44d0 100644 --- a/packages/identity-integration/src/flows/registration.flow.tsx +++ b/packages/identity-integration/src/flows/registration.flow.tsx @@ -1,25 +1,27 @@ -import { Identity } from '@ory/kratos-client' -import { UpdateRegistrationFlowBody } from '@ory/kratos-client' -import { RegistrationFlow as KratosRegistrationFlow } from '@ory/kratos-client' -import { UiNodeInputAttributes } from '@ory/kratos-client' - -import React from 'react' -import { AxiosError } from 'axios' -import { PropsWithChildren } from 'react' -import { FC } from 'react' -import { useSearchParams } from 'next/navigation' -import { useRouter } from 'next/navigation' -import { useState } from 'react' -import { useEffect } from 'react' -import { useMemo } from 'react' -import { useCallback } from 'react' - -import { FlowProvider } from '../providers' -import { ValuesProvider } from '../providers' -import { ValuesStore } from '../providers' -import { SubmitProvider } from '../providers' -import { useKratosClient } from '../providers' -import { handleFlowError } from './handle-errors.util' +import { Identity } from '@ory/kratos-client' +import { UpdateRegistrationFlowBody } from '@ory/kratos-client' +import { RegistrationFlow as KratosRegistrationFlow } from '@ory/kratos-client' +import { ContinueWith as KratosContinueWith } from '@ory/kratos-client' + +import { UiNodeInputAttributes } from '@ory/kratos-client' + +import React from 'react' +import { AxiosError } from 'axios' +import { PropsWithChildren } from 'react' +import { FC } from 'react' +import { useSearchParams } from 'next/navigation' +import { useRouter } from 'next/navigation' +import { useState } from 'react' +import { useEffect } from 'react' +import { useMemo } from 'react' +import { useCallback } from 'react' + +import { FlowProvider } from '../providers' +import { ValuesProvider } from '../providers' +import { ValuesStore } from '../providers' +import { SubmitProvider } from '../providers' +import { useKratosClient } from '../providers' +import { handleFlowError } from './handle-errors.util' export interface RegistrationFlowProps { onError?: (error: { id: string }) => void @@ -27,6 +29,14 @@ export interface RegistrationFlowProps { shouldRedirect?: boolean } +type ContinueWith = KratosContinueWith & { + flow?: { + id: string + url?: string + verifiable_address: string + } +} + export const RegistrationFlow: FC> = ({ children, onError, @@ -121,10 +131,21 @@ export const RegistrationFlow: FC> = ({ setIdentity(data.identity) setIsValid(true) + const continueWithAction: ContinueWith | undefined = data.continue_with?.find( + (action) => action.action === 'show_verification_ui' + ) + if (flow?.return_to) { window.location.href = flow?.return_to } else if (shouldRedirect) { - router.push(returnToUrl ?? '/') + if (returnToUrl) { + router.push(returnToUrl) + } + if (continueWithAction?.flow?.url) { + router.push(continueWithAction.flow.url) + } else { + router.push('/') + } } }) .catch(handleFlowError(router, 'registration', setFlow, returnToSettingsUrl))