Skip to content

Commit

Permalink
Merge pull request #287 from rupato-deriv/Rupato/Fix--oauth-route-aft…
Browse files Browse the repository at this point in the history
…er-callback

fix: oauth route after the callback
  • Loading branch information
rupato-deriv authored Feb 19, 2025
2 parents 1df6d60 + 9a3d0f9 commit f7c4bc4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
36 changes: 18 additions & 18 deletions src/components/layout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const Layout = () => {
Object.values(checkClientAccount).some(account => account.currency === currency) ||
currency === 'demo' ||
currency === '';
const [clientHasCurrency] = useState(ifClientAccountHasCurrency);
const [clientHasCurrency, setClientHasCurrency] = useState(ifClientAccountHasCurrency);

const validCurrencies = [...fiat_currencies_display_order, ...crypto_currencies_display_order];
const query_currency = (getQueryParams.get('account') ?? '')?.toUpperCase();
Expand All @@ -40,21 +40,21 @@ const Layout = () => {
const validateApiAccounts = ({ data }: any) => {

Check warning on line 40 in src/components/layout/index.tsx

View workflow job for this annotation

GitHub Actions / build_to_cloudflare_pages

Unexpected any. Specify a different type
if (data.msg_type === 'authorize') {
api_accounts.push(data.authorize.account_list || []);
console.log('api_accounts', api_accounts);
console.log('checkClientAccount', checkClientAccount);
api_accounts?.flat().map(data => {
Object.values(checkClientAccount).map(key => {
console.log('outside data.currency', data.currency);
console.log('outside key.currency', key.currency);
if (data.currency !== key.currency) {
console.log('setClientHasCurrency');
console.log('data.currency', data.currency);
console.log('key.currency', key.currency);
//setClientHasCurrency(false);
}
});
const allCurrencies = new Set(Object.values(checkClientAccount).map(acc => acc.currency));

const hasMissingCurrency = api_accounts?.flat().some(data => {
if (!allCurrencies.has(data.currency)) {
return true;
}
return false;
});

if (hasMissingCurrency) {
setClientHasCurrency(false);
} else {
console.log('All currencies are present');
}

if (subscription) {
subscription?.unsubscribe();
}
Expand All @@ -68,11 +68,11 @@ const Layout = () => {
}
}, []);

console.log('clientHasCurrency', clientHasCurrency);

useEffect(() => {
if (isLoggedInCookie && !isClientAccountsPopulated && isOAuth2Enabled && !isEndpointPage && !isCallbackPage) {
console.log('requestOidcAuthentication');
if (
(isLoggedInCookie && !isClientAccountsPopulated && isOAuth2Enabled && !isEndpointPage && !isCallbackPage) ||
!clientHasCurrency
) {
requestOidcAuthentication({
redirectCallbackUri: `${window.location.origin}/callback`,
});
Expand Down
2 changes: 1 addition & 1 deletion src/pages/callback/callback-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const CallbackPage = () => {
localStorage.setItem('active_loginid', tokens.acct1);
}

window.location.assign('/');
window.location.assign(window.history.state?.from || '/');
}}
renderReturnButton={() => {
return (
Expand Down

0 comments on commit f7c4bc4

Please sign in to comment.