Skip to content

Commit

Permalink
Adrienne / Fix issue with TH redirection not clearing local storage (#…
Browse files Browse the repository at this point in the history
…18096)

* feat: store redirect metadata for traders hub from os-redirect

* Merge branch 'master' of github.com:deriv-com/deriv-app

* chore: wait for store to be initialised
  • Loading branch information
adrienne-deriv authored Mar 4, 2025
1 parent 18cf193 commit f66d098
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const RootComponent = observer(props => {
setIsWalletsOnboardingTourGuideVisible,
notification_messages_ui,
} = ui;
const { has_wallet, logout, prevent_redirect_to_hub } = client;
const { has_wallet, logout, prevent_redirect_to_hub, is_client_store_initialized } = client;

const { oAuthLogout } = useOauth2({ handleLogout: logout });

Expand All @@ -38,19 +38,19 @@ const RootComponent = observer(props => {
const STAGING_REDIRECT_URL = 'https://staging-hub.deriv.com/tradershub/home';

useEffect(() => {
if (isHubRedirectionEnabled && has_wallet && !prevent_redirect_to_hub) {
if (isHubRedirectionEnabled && has_wallet && !prevent_redirect_to_hub && is_client_store_initialized) {
const redirectUrl = process.env.NODE_ENV === 'production' ? PRODUCTION_REDIRECT_URL : STAGING_REDIRECT_URL;
// NOTE: Clear OIDC related local storage, this is to prevent OIDC to re-apply client.accounts again from the callback page
localStorage.removeItem('config.account1');
localStorage.removeItem('config.tokens');
// NOTE: Clear local storage to prevent user from being logged in at Deriv.app since they should be logged in at low-code Traders Hub only
localStorage.removeItem('active_loginid');
localStorage.removeItem('active_user_id');
localStorage.removeItem('client.accounts');
localStorage.removeItem('active_wallet_loginid');
// NOTE: Clear OIDC related local storage, this is to prevent OIDC to re-apply client.accounts again from the callback page
localStorage.removeItem('config.account1');
localStorage.removeItem('config.tokens');
window.location.assign(redirectUrl);
}
}, [isHubRedirectionEnabled, has_wallet, prevent_redirect_to_hub]);
}, [isHubRedirectionEnabled, has_wallet, prevent_redirect_to_hub, is_client_store_initialized]);

return has_wallet ? (
<Wallets
Expand Down

0 comments on commit f66d098

Please sign in to comment.