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 <peeroke@gmail.com>
pull/1850/head
Agusti Fernandez 2022-02-15 11:34:12 +01:00 committed by GitHub
parent 5f4bd87f0d
commit 5445ca5944
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -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 = (
<span>
@ -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