Skip to content

Commit

Permalink
Merge pull request #1007 from multiversx/development
Browse files Browse the repository at this point in the history
2.26.4
  • Loading branch information
razvantomegea authored Jan 4, 2024
2 parents 8f08938 + 92f4622 commit 4fc8b69
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [[v2.26.4]](https://github.com/multiversx/mx-sdk-dapp/pull/1007)] - 2024-01-04
- [Prevent redirects on logout if the provider is both of wallet type and initialised](https://github.com/multiversx/mx-sdk-dapp/pull/1006)

## [[v2.26.3]](https://github.com/multiversx/mx-sdk-dapp/pull/1005)] - 2024-01-03
- [Fix logout issue with web-wallet](https://github.com/multiversx/mx-sdk-dapp/pull/1004)

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@multiversx/sdk-dapp",
"version": "2.26.3",
"version": "2.26.4",
"description": "A library to hold the main logic for a dapp on the MultiversX blockchain",
"author": "MultiversX",
"license": "GPL-3.0-or-later",
Expand Down
10 changes: 7 additions & 3 deletions src/utils/logout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export async function logout(
const provider = getAccountProvider();
const providerType = getProviderType(provider);
const isWalletProvider = providerType === LoginMethodsEnum.wallet;
const isProviderInitialised = provider?.isInitialized?.() != null;

if (shouldAttemptReLogin && provider?.relogin != null) {
return provider.relogin();
Expand All @@ -69,12 +70,15 @@ export async function logout(

// Prevent page redirect if the logout callbackURL is equal to the current URL
// or if is wallet provider
if (matchPath(location.pathname, callbackPathname) || isWalletProvider) {
if (
matchPath(location.pathname, callbackPathname) ||
(isWalletProvider && isProviderInitialised)
) {
preventRedirects();
}

// We are already logged out, so we can redirect to the dapp
if (!address && provider?.isInitialized?.() == null) {
if (!address && !isProviderInitialised) {
return redirectToCallbackUrl({
callbackUrl: url,
onRedirect
Expand All @@ -84,7 +88,7 @@ export async function logout(
try {
store.dispatch(logoutAction());

if (providerType === LoginMethodsEnum.wallet) {
if (isWalletProvider) {
// Allow redux store cleanup before redirect to web wallet
return setTimeout(() => {
provider.logout({ callbackUrl: url });
Expand Down

0 comments on commit 4fc8b69

Please sign in to comment.