Skip to content

Commit

Permalink
fix: auth url fix
Browse files Browse the repository at this point in the history
  • Loading branch information
agrim-deriv committed Jun 12, 2024
1 parent 3e03938 commit 6284d2a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
6 changes: 1 addition & 5 deletions src/hooks/useLoginUrl/index.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import { generateLoginUrl, getServerConfig } from '@site/src/utils';
import { useCallback } from 'react';
import { useLocation } from '@docusaurus/router';
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';

const useLoginUrl = () => {
const {
i18n: { currentLocale },
} = useDocusaurusContext();
const location = useLocation();
const getUrl = useCallback(
(language = currentLocale) => {
(language = 'en') => {
const { appId, oauth } = getServerConfig();
const pathname = window.location.pathname;
const route = pathname.replace(/\//g, '%2F'); //replacement is done for backend to understand the route
Expand Down
13 changes: 7 additions & 6 deletions src/pages/auth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ export default function Auth(): JSX.Element {
checkUrlParams(search);
}, [checkUrlParams, search]);

if (is_logged_in) {
const params = new URLSearchParams(search);
const redirect_route = params.get('route')?.replace(/%2F/g, '/') || '/';

return <Redirect to={redirect_route} />;
}
useEffect(() => {
if (is_logged_in) {
const params = new URLSearchParams(search);
const redirect_route = params.get('route')?.replace(/%2F/g, '/') || '/';
window.location.assign(window.location.origin + redirect_route);
}
}, [is_logged_in, search]);

return (
<Layout title='Auth' description='Deriv API documentation'>
Expand Down

0 comments on commit 6284d2a

Please sign in to comment.