Skip to content

Commit fecc99d

Browse files
authored
chore(clerk-js): Introduce __internal_hasAfterAuthFlows flag (#6366)
1 parent 959d63d commit fecc99d

File tree

6 files changed

+22
-6
lines changed

6 files changed

+22
-6
lines changed

.changeset/clean-grapes-allow.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@clerk/clerk-js': patch
3+
'@clerk/clerk-react': patch
4+
'@clerk/types': patch
5+
---
6+
7+
Introduce `__internal_hasAfterAuthFlows` flag

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2524,6 +2524,10 @@ export class Clerk implements ClerkInterface {
25242524
this.#emit();
25252525
};
25262526

2527+
get __internal_hasAfterAuthFlows() {
2528+
return !!this.environment?.organizationSettings?.forceOrganizationSelection;
2529+
}
2530+
25272531
#defaultSession = (client: ClientResource): SignedInSessionResource | null => {
25282532
if (client.lastActiveSessionId) {
25292533
const currentSession = client.signedInSessions.find(s => s.id === client.lastActiveSessionId);

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,11 +235,10 @@ export class SignIn extends BaseResource implements SignInResource {
235235

236236
const redirectUrlWithAuthToken = SignIn.clerk.buildUrlWithAuth(redirectUrl);
237237

238-
// When force organization selection is enabled, redirect to SSO callback route.
238+
// When after-auth is enabled, redirect to SSO callback route.
239239
// This ensures organization selection tasks are displayed after sign-in,
240240
// rather than redirecting to potentially unprotected pages while the session is pending.
241-
const actionCompleteRedirectUrl = SignIn.clerk.__unstable__environment?.organizationSettings
242-
.forceOrganizationSelection
241+
const actionCompleteRedirectUrl = SignIn.clerk.__internal_hasAfterAuthFlows
243242
? redirectUrlWithAuthToken
244243
: redirectUrlComplete;
245244

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -290,11 +290,10 @@ export class SignUp extends BaseResource implements SignUpResource {
290290

291291
const redirectUrlWithAuthToken = SignUp.clerk.buildUrlWithAuth(redirectUrl);
292292

293-
// When force organization selection is enabled, redirect to SSO callback route.
293+
// When force after-auth is enabled, redirect to SSO callback route.
294294
// This ensures organization selection tasks are displayed after sign-up,
295295
// rather than redirecting to potentially unprotected pages while the session is pending.
296-
const actionCompleteRedirectUrl = SignUp.clerk.__unstable__environment?.organizationSettings
297-
.forceOrganizationSelection
296+
const actionCompleteRedirectUrl = SignUp.clerk.__internal_hasAfterAuthFlows
298297
? redirectUrlWithAuthToken
299298
: redirectUrlComplete;
300299

packages/react/src/isomorphicClerk.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ type IsomorphicLoadedClerk = Without<
105105
| 'apiKeys'
106106
| '__internal_setComponentNavigationContext'
107107
| '__internal_setActiveInProgress'
108+
| '__internal_hasAfterAuthFlows'
108109
> & {
109110
client: ClientResource | undefined;
110111
billing: CommerceBillingNamespace | undefined;

packages/types/src/clerk.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -841,6 +841,12 @@ export interface Clerk {
841841
*/
842842
__internal_setActiveInProgress: boolean;
843843

844+
/**
845+
* Internal flag indicating whether after-auth flows are enabled based on instance settings.
846+
* @internal
847+
*/
848+
__internal_hasAfterAuthFlows: boolean;
849+
844850
/**
845851
* API Keys Object
846852
* @experimental

0 commit comments

Comments
 (0)