From 551a466f368a2b6b1de0c65c96649567d6e23fb2 Mon Sep 17 00:00:00 2001 From: Habib Deriv <88178645+habib-deriv@users.noreply.github.com> Date: Fri, 1 Aug 2025 16:51:17 +0800 Subject: [PATCH 1/2] fix: improve wallet redirect handling --- .../src/containers/routes/binary-routes.tsx | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/packages/cashier/src/containers/routes/binary-routes.tsx b/packages/cashier/src/containers/routes/binary-routes.tsx index 02c1f6c478cb..f76c7ff03b09 100644 --- a/packages/cashier/src/containers/routes/binary-routes.tsx +++ b/packages/cashier/src/containers/routes/binary-routes.tsx @@ -3,7 +3,7 @@ import { Switch } from 'react-router-dom'; import { Loading } from '@deriv/components'; import { useIsHubRedirectionEnabled } from '@deriv/hooks'; -import { deriv_urls, getDomainUrl } from '@deriv/shared'; +import { getDomainUrl } from '@deriv/shared'; import { useStore } from '@deriv/stores'; import getRoutesConfig from 'Constants/routes-config'; @@ -32,9 +32,14 @@ const BinaryRoutes = (props: TBinaryRoutesProps) => { const STAGING_REDIRECT_URL = `https://staging-hub.${getDomainUrl()}/tradershub`; useEffect(() => { + if (has_wallet === undefined) { + // eslint-disable-next-line no-console + console.error('Unable to retrieve wallet information from API.'); + } + if ( isHubRedirectionEnabled && - has_wallet && + Boolean(has_wallet) && !is_logging_out && is_logged_in && !prevent_redirect_to_hub && @@ -42,15 +47,10 @@ const BinaryRoutes = (props: TBinaryRoutesProps) => { ) { const redirectUrl = process.env.NODE_ENV === 'production' ? PRODUCTION_REDIRECT_URL : STAGING_REDIRECT_URL; - const domain = /deriv\.(com|me|be)/.test(window.location.hostname) - ? deriv_urls.DERIV_HOST_NAME - : window.location.hostname; - Cookies.set('wallet_account', true, { domain }); - const url_query_string = window.location.search; const url_params = new URLSearchParams(url_query_string); const account_currency = window.sessionStorage.getItem('account') || url_params.get('account'); - localStorage.setItem('wallet_redirect_done', true); + localStorage.setItem('wallet_redirect_done', 'true'); const redirect_path = `${redirectUrl}/redirect?action=redirect_to&redirect_to=wallet${account_currency ? `&account=${account_currency}` : ''}`; window.location.href = redirect_path; } @@ -59,6 +59,7 @@ const BinaryRoutes = (props: TBinaryRoutesProps) => { if (prevent_single_login && isHubRedirectionLoaded && is_client_store_initialized && shouldStayInDerivApp) { setPreventSingleLogin(false); } + // eslint-disable-next-line react-hooks/exhaustive-deps }, [ isHubRedirectionLoaded, isHubRedirectionEnabled, From 06220473829a6d43217fd8a80b797700149990b6 Mon Sep 17 00:00:00 2001 From: Habib Deriv <88178645+habib-deriv@users.noreply.github.com> Date: Fri, 1 Aug 2025 16:54:10 +0800 Subject: [PATCH 2/2] Update packages/cashier/src/containers/routes/binary-routes.tsx --- packages/cashier/src/containers/routes/binary-routes.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cashier/src/containers/routes/binary-routes.tsx b/packages/cashier/src/containers/routes/binary-routes.tsx index f76c7ff03b09..4267665cfdd1 100644 --- a/packages/cashier/src/containers/routes/binary-routes.tsx +++ b/packages/cashier/src/containers/routes/binary-routes.tsx @@ -39,7 +39,7 @@ const BinaryRoutes = (props: TBinaryRoutesProps) => { if ( isHubRedirectionEnabled && - Boolean(has_wallet) && + has_wallet && !is_logging_out && is_logged_in && !prevent_redirect_to_hub &&