diff --git a/packages/core/src/App/Containers/RootComponent/root-component.jsx b/packages/core/src/App/Containers/RootComponent/root-component.jsx index 000718a9251f..55fa4783646f 100644 --- a/packages/core/src/App/Containers/RootComponent/root-component.jsx +++ b/packages/core/src/App/Containers/RootComponent/root-component.jsx @@ -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 }); @@ -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 ? (