Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adrienne / Hotfix TH redirection not clearing storage #18095

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading