From 7077d25a2ece37dbf55b66732bd76942e2436239 Mon Sep 17 00:00:00 2001 From: Melisa Anabella Rossi Date: Fri, 22 Dec 2023 13:54:11 -0300 Subject: [PATCH] fix: decode uri component redirectTo --- src/components/Pages/CallbackPage/CallbackPage.tsx | 2 +- src/components/Pages/LoginPage/LoginPage.tsx | 2 +- src/hooks/redirection.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/Pages/CallbackPage/CallbackPage.tsx b/src/components/Pages/CallbackPage/CallbackPage.tsx index 43040d0..d530e8b 100644 --- a/src/components/Pages/CallbackPage/CallbackPage.tsx +++ b/src/components/Pages/CallbackPage/CallbackPage.tsx @@ -37,7 +37,7 @@ export const CallbackPage = () => { setIsLoading(false) await getUserSignature() if (redirectTo) { - window.location.href = redirectTo + window.location.href = decodeURIComponent(redirectTo) } else { // Navigate to user or to any other site // TODO: Navigate to the landing page. diff --git a/src/components/Pages/LoginPage/LoginPage.tsx b/src/components/Pages/LoginPage/LoginPage.tsx index 5a1d9e5..f1da621 100644 --- a/src/components/Pages/LoginPage/LoginPage.tsx +++ b/src/components/Pages/LoginPage/LoginPage.tsx @@ -32,7 +32,7 @@ export const LoginPage = () => { setConnectionModalState(ConnectionModalState.WAITING_FOR_SIGNATURE) await getSignature(connectionData.account?.toLowerCase() ?? '', connectionData.provider) if (redirectTo) { - window.location.href = redirectTo + window.location.href = decodeURIComponent(redirectTo) } else { navigate('/user') } diff --git a/src/hooks/redirection.ts b/src/hooks/redirection.ts index 688aa07..ba503aa 100644 --- a/src/hooks/redirection.ts +++ b/src/hooks/redirection.ts @@ -3,7 +3,7 @@ import { useLocation } from 'react-router-dom' export const useAfterLoginRedirection = () => { const location = useLocation() const search = new URLSearchParams(location.search) - const redirectToSearchParam = search.get('redirectTo') + const redirectToSearchParam = decodeURIComponent(search.get('redirectTo') || '') if (redirectToSearchParam === null) { return undefined