Skip to content

fix(clerk-js): Force redirect to sso-callback if force-an-org is enabled #6271

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Set redirectUrl as actionCompleteRedirectUrl if force-an-org is e…
…nabled
  • Loading branch information
LauraBeatris committed Jul 9, 2025
commit 865d4ab2e9eb2408fec0c0b9310255e1dfccc22c
5 changes: 5 additions & 0 deletions .changeset/public-hats-relax.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clerk/clerk-js': patch
---

Force redirect to SSO callback route when force-an-org is enabled, ensuring task display and organization selection
16 changes: 13 additions & 3 deletions packages/clerk-js/src/core/resources/SignIn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,20 +233,30 @@ export class SignIn extends BaseResource implements SignInResource {
): Promise<void> => {
const { strategy, redirectUrl, redirectUrlComplete, identifier, oidcPrompt, continueSignIn } = params || {};

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

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

if (!this.id || !continueSignIn) {
await this.create({
strategy,
identifier,
redirectUrl: SignIn.clerk.buildUrlWithAuth(redirectUrl),
actionCompleteRedirectUrl: redirectUrlComplete,
redirectUrl: redirectUrlWithAuthToken,
actionCompleteRedirectUrl,
});
}

if (strategy === 'saml' || strategy === 'enterprise_sso') {
await this.prepareFirstFactor({
strategy,
redirectUrl: SignIn.clerk.buildUrlWithAuth(redirectUrl),
actionCompleteRedirectUrl: redirectUrlComplete,
actionCompleteRedirectUrl,
oidcPrompt,
});
}
Expand Down
14 changes: 12 additions & 2 deletions packages/clerk-js/src/core/resources/SignUp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,11 +288,21 @@ export class SignUp extends BaseResource implements SignUpResource {
oidcPrompt,
} = params;

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

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

const authenticateFn = () => {
const authParams = {
strategy,
redirectUrl: SignUp.clerk.buildUrlWithAuth(redirectUrl),
actionCompleteRedirectUrl: redirectUrlComplete,
redirectUrl: redirectUrlWithAuthToken,
actionCompleteRedirectUrl,
unsafeMetadata,
emailAddress,
legalAccepted,
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy