From 941a14a8e474422f24f5b874456b43fc9739cfef Mon Sep 17 00:00:00 2001 From: Laura Beatris <48022589+LauraBeatris@users.noreply.github.com> Date: Thu, 16 Jan 2025 19:36:34 -0300 Subject: [PATCH] Fix sign in router for `enterprise_sso` --- .../machines/sign-in/router.machine.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/packages/elements/src/internals/machines/sign-in/router.machine.ts b/packages/elements/src/internals/machines/sign-in/router.machine.ts index ecd0446b29..ea6dcdd9ba 100644 --- a/packages/elements/src/internals/machines/sign-in/router.machine.ts +++ b/packages/elements/src/internals/machines/sign-in/router.machine.ts @@ -204,7 +204,7 @@ export const SignInRouterMachine = setup({ }, })), }, - 'AUTHENTICATE.ENTERPRISE_SSO': { + 'AUTHENTICATE.SAML': { actions: sendTo(ThirdPartyMachineId, ({ context }) => ({ type: 'REDIRECT', params: { @@ -220,6 +220,22 @@ export const SignInRouterMachine = setup({ }, })), }, + 'AUTHENTICATE.ENTERPRISE_SSO': { + actions: sendTo(ThirdPartyMachineId, ({ context }) => ({ + type: 'REDIRECT', + params: { + strategy: 'enterprise_sso', + identifier: context.formRef.getSnapshot().context.fields.get('identifier')?.value, + redirectUrl: `${ + context.router?.mode === ROUTING.virtual + ? context.clerk.__unstable__environment?.displayConfig.signInUrl + : context.router?.basePath + }${SSO_CALLBACK_PATH_ROUTE}`, + redirectUrlComplete: + context.router?.searchParams().get('redirect_url') || context.clerk.buildAfterSignInUrl(), + }, + })), + }, 'FORM.ATTACH': { description: 'Attach/re-attach the form to the router.', actions: enqueueActions(({ enqueue, event }) => {