Skip to content

Commit

Permalink
chore: conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
Thisyahlen committed Dec 12, 2024
1 parent 1b63531 commit 80d3de9
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { redirectToLogin } from '@deriv/shared';
import { observer, useStore } from '@deriv/stores';
import { getLanguage, Localize, localize } from '@deriv/translations';
import { Analytics, TEvents } from '@deriv-com/analytics';
import { requestOidcAuthentication } from '@deriv-com/auth-client';

import './wallets-upgrade-logout-modal.scss';

Expand All @@ -29,12 +30,16 @@ const WalletsUpgradeLogoutModal = observer(() => {
const { is_desktop } = ui;
const account_mode = is_virtual ? 'demo' : 'real';

const { loginHandler, oAuthLogout } = useOauth2({
const { oAuthLogout, isOAuth2Enabled } = useOauth2({
handleLogout: async () => {
await logout();
},
handleLogin: async () => {
await redirectToLogin(false, getLanguage());
if (isOAuth2Enabled) {
await requestOidcAuthentication({
redirectCallbackUri: `${window.location.origin}/callback`,
});
} else {
redirectToLogin(false, getLanguage());
}
},
});

Expand All @@ -48,9 +53,7 @@ const WalletsUpgradeLogoutModal = observer(() => {
expires: 0.5, // 12 hours expiration time
secure: true,
});
oAuthLogout().then(async () => {
await loginHandler();
});
await oAuthLogout();
trackAnalyticsEvent('click_cta', account_mode);
};

Expand Down
9 changes: 8 additions & 1 deletion packages/core/src/Modules/Callback/CallbackPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@ const CallbackPage = () => {
}}
renderReturnButton={() => {
return (
<Button onClick={() => history.push('/')} secondary is_circular>
<Button
onClick={() => {
history.push('/');
window.location.reload();
}}
secondary
is_circular
>
<Localize i18n_default_text='Try again' />
</Button>
);
Expand Down
12 changes: 4 additions & 8 deletions packages/hooks/src/useOauth2.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { redirectToLogin } from '@deriv/shared';
import { getLanguage } from '@deriv/translations';
import {
OAuth2Logout,
requestOidcAuthentication,
Expand All @@ -20,13 +22,7 @@ import useGrowthbookGetFeatureValue from './useGrowthbookGetFeatureValue';
* @param {{ handleLogout?: () => Promise<void> }} [options] - An object with an optional `handleLogout` property.
* @returns {{ isOAuth2Enabled: boolean; oAuthLogout: () => Promise<void> }}
*/
const useOauth2 = ({
handleLogout,
handleLogin,
}: {
handleLogout: () => Promise<void>;
handleLogin?: () => Promise<void>;
}) => {
const useOauth2 = ({ handleLogout }: { handleLogout: () => Promise<void> }) => {
const [oAuth2EnabledApps, OAuth2EnabledAppsInitialised] = useGrowthbookGetFeatureValue<string>({
featureFlag: 'hydra_be',
}) as unknown as [TOAuth2EnabledAppList, boolean];
Expand All @@ -39,7 +35,7 @@ const useOauth2 = ({
redirectCallbackUri: `${window.location.origin}/callback`,
});
}
await handleLogin?.();
redirectToLogin(false, getLanguage());
};

const logoutHandler = async () => {
Expand Down

0 comments on commit 80d3de9

Please sign in to comment.