From a8bd73b76dd0ea2e024f8ceb4d862d22af8bc92b Mon Sep 17 00:00:00 2001 From: Mohammad Cheikh Date: Thu, 13 Feb 2025 14:31:42 -0500 Subject: [PATCH] add changeset --- .changeset/proud-moles-lie.md | 5 +++++ packages/sdk-react/src/components/auth/Auth.tsx | 10 +++++----- 2 files changed, 10 insertions(+), 5 deletions(-) create mode 100644 .changeset/proud-moles-lie.md diff --git a/.changeset/proud-moles-lie.md b/.changeset/proud-moles-lie.md new file mode 100644 index 000000000..455ab1502 --- /dev/null +++ b/.changeset/proud-moles-lie.md @@ -0,0 +1,5 @@ +--- +"@turnkey/sdk-react": patch +--- + +Fix issue with EWK where suborgs were being created on failed fetches diff --git a/packages/sdk-react/src/components/auth/Auth.tsx b/packages/sdk-react/src/components/auth/Auth.tsx index 1ccaf67e8..044da276c 100644 --- a/packages/sdk-react/src/components/auth/Auth.tsx +++ b/packages/sdk-react/src/components/auth/Auth.tsx @@ -142,7 +142,7 @@ const Auth: React.FC = ({ !getVerifiedSuborgsResponse.organizationIds ) { onError(authErrors.suborg.fetchFailed); - return; + return null; } suborgId = getVerifiedSuborgsResponse?.organizationIds[0]; } else { @@ -152,7 +152,7 @@ const Auth: React.FC = ({ }); if (!getSuborgsResponse || !getSuborgsResponse.organizationIds) { onError(authErrors.suborg.fetchFailed); - return; + return null; } suborgId = getSuborgsResponse?.organizationIds[0]; } @@ -265,14 +265,14 @@ const Auth: React.FC = ({ ) => { const suborgId = await handleGetOrCreateSuborg(type, value); const initAuthResponse = await server.sendOtp({ - suborgID: suborgId, + suborgID: suborgId!, otpType, contact: value, ...(customSmsMessage && { customSmsMessage }), userIdentifier: authIframeClient?.iframePublicKey!, }); if (initAuthResponse && initAuthResponse.otpId) { - setSuborgId(suborgId); + setSuborgId(suborgId!); setOtpId(initAuthResponse?.otpId!); setStep(otpType); } else { @@ -290,7 +290,7 @@ const Auth: React.FC = ({ }, ); const oauthResponse = await server.oauth({ - suborgID: suborgId, + suborgID: suborgId!, oidcToken: credential, targetPublicKey: authIframeClient?.iframePublicKey!, sessionLengthSeconds: authConfig.sessionLengthSeconds,