Skip to content

Commit e3d073e

Browse files
authored
fix(clerk-js): Fix multi-session navigation for hash routing (#6461)
1 parent d90ce4c commit e3d073e

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

.changeset/warm-lies-dance.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+
Fix multi-session navigation for hash routing

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1580,20 +1580,27 @@ export class Clerk implements ClerkInterface {
15801580
}
15811581

15821582
public buildAfterMultiSessionSingleSignOutUrl(): string {
1583-
if (!this.#options.afterMultiSessionSingleSignOutUrl) {
1583+
if (!this.environment) {
1584+
return '';
1585+
}
1586+
1587+
if (this.#options.afterMultiSessionSingleSignOutUrl) {
1588+
return this.buildUrlWithAuth(this.#options.afterMultiSessionSingleSignOutUrl);
1589+
}
1590+
1591+
if (this.#options.signInUrl) {
15841592
return this.buildUrlWithAuth(
15851593
buildURL(
15861594
{
1587-
base: this.#options.signInUrl
1588-
? `${this.#options.signInUrl}/choose`
1589-
: this.environment?.displayConfig.afterSignOutOneUrl,
1595+
base: this.#options.signInUrl,
1596+
hashPath: 'choose',
15901597
},
15911598
{ stringify: true },
15921599
),
15931600
);
15941601
}
15951602

1596-
return this.buildUrlWithAuth(this.#options.afterMultiSessionSingleSignOutUrl);
1603+
return this.buildUrlWithAuth(this.environment.displayConfig.afterSignOutOneUrl);
15971604
}
15981605

15991606
public buildCreateOrganizationUrl(): string {

packages/clerk-js/src/ui/components/SignIn/SignInAccountSwitcher.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ import { useMultisessionActions } from '../UserButton/useMultisessionActions';
1515
const SignInAccountSwitcherInternal = () => {
1616
const card = useCardState();
1717
const { userProfileUrl } = useEnvironment().displayConfig;
18-
const { afterSignInUrl, path: signInPath } = useSignInContext();
18+
const { afterSignInUrl, path: signInPath, signInUrl } = useSignInContext();
1919
const { navigateAfterSignOut } = useSignOutContext();
2020
const { handleSignOutAllClicked, handleSessionClicked, signedInSessions, handleAddAccountClicked } =
2121
useMultisessionActions({
2222
navigateAfterSignOut,
2323
afterSwitchSessionUrl: afterSignInUrl,
2424
userProfileUrl,
25-
signInUrl: signInPath,
25+
signInUrl: signInPath ?? signInUrl,
2626
user: undefined,
2727
});
2828

0 commit comments

Comments
 (0)