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

chore: redirect to auth straight after wallet migration #17361

Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import React from 'react';
import { Analytics, TEvents } from '@deriv-com/analytics';
import Cookies from 'js-cookie';
import { Dialog, Icon, Text } from '@deriv/components';
import { redirectToLogin, routes } from '@deriv/shared';
import { redirectToLogin } from '@deriv/shared';
import { observer, useStore } from '@deriv/stores';
import { getLanguage, localize, Localize } from '@deriv/translations';
import { useOauth2 } from '@deriv/hooks';
import './wallets-upgrade-logout-modal.scss';

const trackAnalyticsEvent = (
Expand All @@ -30,24 +31,26 @@ const WalletsUpgradeLogoutModal = observer(() => {
trackAnalyticsEvent('open', account_mode);
}, [account_mode]);

const onConfirmHandler = () => {
const onConfirmHandler = async () => {
Cookies.set('recent_wallets_migration', 'true', {
path: '/', // not available on other subdomains
expires: 0.5, // 12 hours expiration time
secure: true,
});

logout().then(() => {
window.location.href = routes.traders_hub;
redirectToLogin(false, getLanguage());
});
trackAnalyticsEvent('click_cta', account_mode);
};

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

return (
<Dialog
className='wallets-upgrade-logout-modal'
confirm_button_text={localize('Log out')}
onConfirm={onConfirmHandler}
onConfirm={oAuthLogout}
is_closed_on_confirm
is_visible
dismissable={false}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import { moduleLoader } from '@deriv/shared';
import { useOauth2 } from '@deriv/hooks';
import { observer, useStore } from '@deriv/stores';

const AppStore = React.lazy(() =>
Expand All @@ -21,6 +22,8 @@ const RootComponent = observer(props => {
const { is_wallets_onboarding_tour_guide_visible, setIsWalletsOnboardingTourGuideVisible } = ui;
const { has_wallet, logout } = client;

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

const onWalletsOnboardingTourGuideCloseHandler = () => {
setIsWalletsOnboardingTourGuideVisible(false);
};
Expand All @@ -29,7 +32,7 @@ const RootComponent = observer(props => {
<Wallets
isWalletsOnboardingTourGuideVisible={is_wallets_onboarding_tour_guide_visible}
logout={async () => {
await logout();
await oAuthLogout();
}}
onWalletsOnboardingTourGuideCloseHandler={onWalletsOnboardingTourGuideCloseHandler}
/>
Expand Down
Loading