Skip to content

Commit

Permalink
Merge pull-request #505
Browse files Browse the repository at this point in the history
  • Loading branch information
moe-dev committed Feb 13, 2025
2 parents 7e44349 + a8bd73b commit 0ca20ca
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/proud-moles-lie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@turnkey/sdk-react": patch
---

Fix issue with EWK where suborgs were being created on failed fetches
8 changes: 5 additions & 3 deletions packages/sdk-react/src/components/auth/Auth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ const Auth: React.FC<AuthProps> = ({
!getVerifiedSuborgsResponse.organizationIds
) {
onError(authErrors.suborg.fetchFailed);
return null;
}
suborgId = getVerifiedSuborgsResponse?.organizationIds[0];
} else {
Expand All @@ -151,6 +152,7 @@ const Auth: React.FC<AuthProps> = ({
});
if (!getSuborgsResponse || !getSuborgsResponse.organizationIds) {
onError(authErrors.suborg.fetchFailed);
return null;
}
suborgId = getSuborgsResponse?.organizationIds[0];
}
Expand Down Expand Up @@ -281,14 +283,14 @@ const Auth: React.FC<AuthProps> = ({
) => {
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 {
Expand All @@ -306,7 +308,7 @@ const Auth: React.FC<AuthProps> = ({
},
);
const oauthResponse = await server.oauth({
suborgID: suborgId,
suborgID: suborgId!,
oidcToken: credential,
targetPublicKey: authIframeClient?.iframePublicKey!,
sessionLengthSeconds: authConfig.sessionLengthSeconds,
Expand Down

0 comments on commit 0ca20ca

Please sign in to comment.