Skip to content

Mayuran/fix test link login issue #368

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 26 additions & 22 deletions src/components/layout/header/header.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import clsx from 'clsx';
import { observer } from 'mobx-react-lite';
import { standalone_routes } from '@/components/shared';
import { generateOAuthURL, standalone_routes } from '@/components/shared';
import Button from '@/components/shared_ui/button';
import useActiveAccount from '@/hooks/api/account/useActiveAccount';
import { useOauth2 } from '@/hooks/auth/useOauth2';
Expand Down Expand Up @@ -33,7 +33,7 @@ const AppHeader = observer(() => {
const currency = getCurrency?.();
const { localize } = useTranslations();

const { isSingleLoggingIn } = useOauth2();
const { isOAuth2Enabled, isSingleLoggingIn } = useOauth2();

const renderAccountSection = () => {
if (isAuthorizing || isSingleLoggingIn) {
Expand Down Expand Up @@ -114,27 +114,31 @@ const AppHeader = observer(() => {
<Button
tertiary
onClick={async () => {
const getQueryParams = new URLSearchParams(window.location.search);
const currency = getQueryParams.get('account') ?? '';
const query_param_currency =
sessionStorage.getItem('query_param_currency') || currency || 'USD';
try {
await requestOidcAuthentication({
redirectCallbackUri: `${window.location.origin}/callback`,
...(query_param_currency
? {
state: {
account: query_param_currency,
},
}
: {}),
}).catch(err => {
if (!isOAuth2Enabled) {
window.location.replace(generateOAuthURL());
} else {
const getQueryParams = new URLSearchParams(window.location.search);
const currency = getQueryParams.get('account') ?? '';
const query_param_currency =
sessionStorage.getItem('query_param_currency') || currency || 'USD';
try {
await requestOidcAuthentication({
redirectCallbackUri: `${window.location.origin}/callback`,
...(query_param_currency
? {
state: {
account: query_param_currency,
},
}
: {}),
}).catch(err => {
// eslint-disable-next-line no-console
console.error(err);
});
} catch (error) {
// eslint-disable-next-line no-console
console.error(err);
});
} catch (error) {
// eslint-disable-next-line no-console
console.error(error);
console.error(error);
}
}
}}
>
Expand Down
Loading