Skip to content

Commit

Permalink
Fixed logout doesn't work when shouldBroadcastLogoutAcrossTabs is `…
Browse files Browse the repository at this point in the history
…false`
  • Loading branch information
razvantomegea committed Dec 13, 2024
1 parent 61041fd commit 6b5cf5f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

- [Fixed logout doesn't work when `shouldBroadcastLogoutAcrossTabs` is `false`](https://github.com/multiversx/mx-sdk-dapp/pull/1348)

## [[v3.1.3](https://github.com/multiversx/mx-sdk-dapp/pull/1347)] - 2024-12-13

- [Added session ID in the handshake payload to allow multiple DApp connections in parallel tabs](https://github.com/multiversx/mx-sdk-dapp/pull/1346)
Expand Down
11 changes: 3 additions & 8 deletions src/utils/logout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export async function logout(
hasConsentPopup: false
}
) {
let address = '';
const address = await getAddress();
const provider = getAccountProvider();
const providerType = getProviderType(provider);
const isWalletProvider = providerType === LoginMethodsEnum.wallet;
Expand All @@ -64,13 +64,8 @@ export async function logout(
return provider.relogin();
}

if (options.shouldBroadcastLogoutAcrossTabs) {
try {
address = await getAddress();
broadcastLogoutAcrossTabs(address);
} catch (err) {
console.error('error fetching logout address', err);
}
if (address && options.shouldBroadcastLogoutAcrossTabs) {
broadcastLogoutAcrossTabs(address);
}

const url = addOriginToLocationPath(callbackUrl);
Expand Down

0 comments on commit 6b5cf5f

Please sign in to comment.