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>
This commit is contained in:
parent
5f4bd87f0d
commit
5445ca5944
1 changed files with 3 additions and 2 deletions
|
@ -58,7 +58,8 @@ export default function Login({
|
||||||
|
|
||||||
const telemetry = useTelemetry();
|
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 = (
|
const LoginFooter = (
|
||||||
<span>
|
<span>
|
||||||
|
@ -98,7 +99,7 @@ export default function Login({
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
if (!res) setErrorMessage(errorMessages[ErrorCode.InternalServerError]);
|
if (!res) setErrorMessage(errorMessages[ErrorCode.InternalServerError]);
|
||||||
// we're logged in! let's do a hard refresh to the desired url
|
// 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
|
// reveal two factor input if required
|
||||||
else if (res.error === ErrorCode.SecondFactorRequired) setTwoFactorRequired(true);
|
else if (res.error === ErrorCode.SecondFactorRequired) setTwoFactorRequired(true);
|
||||||
// fallback if error not found
|
// fallback if error not found
|
||||||
|
|
Loading…
Reference in a new issue