From 5445ca5944f4458198812be65042c69a5879d498 Mon Sep 17 00:00:00 2001 From: Agusti Fernandez Date: Tue, 15 Feb 2022 11:34:12 +0100 Subject: [PATCH] Fixes callbackUrl issue in login page (#1848) * fix: remove use of window.location in redirect of callbackUrl in Login Page * Adds WEBSITE_URL constant to callbackUrl in login page Co-authored-by: Peer Richelsen --- apps/web/pages/auth/login.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/web/pages/auth/login.tsx b/apps/web/pages/auth/login.tsx index 89284fcf..50b86120 100644 --- a/apps/web/pages/auth/login.tsx +++ b/apps/web/pages/auth/login.tsx @@ -58,7 +58,8 @@ export default function Login({ const telemetry = useTelemetry(); - const callbackUrl = typeof router.query?.callbackUrl === "string" ? router.query.callbackUrl : "/"; + const callbackUrl = + typeof router.query?.callbackUrl === "string" ? `${WEBSITE_URL}/${router.query.callbackUrl}` : "/"; const LoginFooter = ( @@ -98,7 +99,7 @@ export default function Login({ .then((res) => { if (!res) setErrorMessage(errorMessages[ErrorCode.InternalServerError]); // we're logged in! let's do a hard refresh to the desired url - else if (!res.error) window.location.replace(callbackUrl); + else if (!res.error) router.push(callbackUrl); // reveal two factor input if required else if (res.error === ErrorCode.SecondFactorRequired) setTwoFactorRequired(true); // fallback if error not found