From 6284d2a60636b46648532326b7d26a4370edc16b Mon Sep 17 00:00:00 2001 From: Agrim Jain Date: Wed, 12 Jun 2024 12:33:39 +0400 Subject: [PATCH] fix: auth url fix --- src/hooks/useLoginUrl/index.tsx | 6 +----- src/pages/auth.tsx | 13 +++++++------ 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/hooks/useLoginUrl/index.tsx b/src/hooks/useLoginUrl/index.tsx index 6b6bdf303..ec8cfba57 100644 --- a/src/hooks/useLoginUrl/index.tsx +++ b/src/hooks/useLoginUrl/index.tsx @@ -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 diff --git a/src/pages/auth.tsx b/src/pages/auth.tsx index 558128389..14f84e064 100644 --- a/src/pages/auth.tsx +++ b/src/pages/auth.tsx @@ -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 ; - } + 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 (