diff --git a/src/components/UserNavbarItem/item.desktop.tsx b/src/components/UserNavbarItem/item.desktop.tsx index 32a21933..bbe065ac 100644 --- a/src/components/UserNavbarItem/item.desktop.tsx +++ b/src/components/UserNavbarItem/item.desktop.tsx @@ -34,8 +34,7 @@ const UserNavbarDesktopItem = ({ authUrl, is_logged_in }: IUserNavbarItemProps) const userManager = new UserManager({ authority: data.issuer, client_id: appid, - redirect_uri: - 'https://deriv-api-docs-git-fork-thisyahlen-deriv-thisyahlen-oidc.binary.sx/callback', + redirect_uri: `${window.location.origin}/callback`, response_type: 'code', scope: 'openid', stateStore: new WebStorageStateStore({ store: window.localStorage }), diff --git a/src/features/Callback/index.tsx b/src/features/Callback/index.tsx index 147ac127..6748b745 100644 --- a/src/features/Callback/index.tsx +++ b/src/features/Callback/index.tsx @@ -1,7 +1,10 @@ import React, { useEffect } from 'react'; import axios from 'axios'; +import { getAccountsFromSearchParams } from '@site/src/utils'; +import useAuthContext from '@site/src/hooks/useAuthContext'; export default function CallbackComponent() { + const { updateLoginAccounts } = useAuthContext(); const [error, setError] = React.useState(null); const [error_description, setErrorDescription] = React.useState(null); @@ -36,8 +39,7 @@ export default function CallbackComponent() { }, body: new URLSearchParams({ grant_type: 'authorization_code', - redirect_uri: - 'https://deriv-api-docs-git-fork-thisyahlen-deriv-thisyahlen-oidc.binary.sx/callback', + redirect_uri: `${window.location.origin}/callback`, code: code, code_verifier: code_verifier, client_id: appId, @@ -64,6 +66,9 @@ export default function CallbackComponent() { const legacyData = response.data; console.log('Legacy token fetch successful', legacyData); + const accounts = getAccountsFromSearchParams(legacyData); + updateLoginAccounts(accounts); + window.location.href = '/dashboard'; // You can store or handle the legacy tokens as needed here } catch (error) { if (error.response) {