Skip to content

Commit

Permalink
chore: add logic to not hardcode the origin
Browse files Browse the repository at this point in the history
  • Loading branch information
thisyahlen-deriv committed Oct 14, 2024
1 parent febc538 commit 91de017
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/components/UserNavbarItem/item.desktop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 }),
Expand Down
9 changes: 7 additions & 2 deletions src/features/Callback/index.tsx
Original file line number Diff line number Diff line change
@@ -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<string | null>(null);
const [error_description, setErrorDescription] = React.useState<string | null>(null);

Expand Down Expand Up @@ -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,
Expand All @@ -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) {
Expand Down

0 comments on commit 91de017

Please sign in to comment.