Skip to content

Commit 5dd6089

Browse files
committed
Add guard for empty organization
1 parent 6bd1d2f commit 5dd6089

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

.changeset/petite-ravens-see.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@clerk/clerk-js': patch
3+
---
4+
5+
Do not allow `setActive({ organization: null })` when organization selection is forced

packages/clerk-js/src/core/clerk.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,6 +1071,10 @@ export class Clerk implements ClerkInterface {
10711071
);
10721072
}
10731073

1074+
if (organization === null && this.environment?.organizationSettings?.forceOrganizationSelection) {
1075+
throw new Error('setActive requires an organization parameter when organization selection is forced.');
1076+
}
1077+
10741078
const onBeforeSetActive: SetActiveHook =
10751079
typeof window !== 'undefined' && typeof window.__unstable__onBeforeSetActive === 'function'
10761080
? window.__unstable__onBeforeSetActive

0 commit comments

Comments
 (0)