From e6f8a08e2f9078eb20273e0291ed4aecf75f6ad9 Mon Sep 17 00:00:00 2001 From: Nenad Misic Date: Fri, 5 Jan 2024 04:39:30 +0100 Subject: [PATCH] BG-1005: Fix /auth-redirector URL appearing after redirecting (#2629) * Reinstall yarn pgks * Add setTimeout before redirecting in OAUTHRedirector * Revert yarn.lock --- src/pages/OAuthRedirector.tsx | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/pages/OAuthRedirector.tsx b/src/pages/OAuthRedirector.tsx index 73dba6c4c7..cb8c1970f9 100644 --- a/src/pages/OAuthRedirector.tsx +++ b/src/pages/OAuthRedirector.tsx @@ -1,6 +1,25 @@ -import { Navigate } from "react-router-dom"; +import { useEffect } from "react"; +import { useNavigate } from "react-router-dom"; import { OAUTH_PATH_STORAGE_KEY } from "constants/auth"; +// For some reason aws-amplify redirects to this page twice; the slowness of the 2nd +// redirect causes the final URL to be of this page even though the rendered page is +// completely different (Marketplace, Register etc.). +// To account for this slowness, we set a timeout and navigate to the desired page afterwards. +const DELAY = 300; + export default function OAUTHRedirector() { - return ; + const navigate = useNavigate(); + + useEffect(() => { + const timeout = setTimeout( + () => navigate(localStorage.getItem(OAUTH_PATH_STORAGE_KEY) ?? "/"), + DELAY + ); + return () => { + clearTimeout(timeout); + }; + }, [navigate]); + + return

Redirecting...

; }