Adds BASE_URL to callbackUrl in signup page and Shell component (#1882)

* add WEBSITE_URL to callbackUrl in signup page and Shell component

* fix: WEBSITE_URL -> BASE_URL, login missing do in another pr maybe

Co-authored-by: Agusti Fernandez <agusti@colony.io>
Co-authored-by: Peer Richelsen <peeroke@gmail.com>
Co-authored-by: Agusti Fernandez <git@agusti.me>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
pull/1875/head^2
Agusti Fernandez 2022-02-21 21:09:56 +01:00 committed by GitHub
parent 9863178025
commit 373bc1660c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 4 deletions

View File

@ -22,6 +22,7 @@ import TrialBanner from "@ee/components/TrialBanner";
import HelpMenuItemDynamic from "@ee/lib/intercom/HelpMenuItemDynamic";
import classNames from "@lib/classNames";
import { BASE_URL } from "@lib/config/constants";
import { shouldShowOnboarding } from "@lib/getting-started";
import { useLocale } from "@lib/hooks/useLocale";
import { collectPageParameters, telemetryEventTypes, useTelemetry } from "@lib/telemetry";
@ -61,7 +62,7 @@ function useRedirectToLoginIfUnauthenticated() {
router.replace({
pathname: "/auth/login",
query: {
callbackUrl: `${location.pathname}${location.search}`,
callbackUrl: `${BASE_URL}/${location.pathname}${location.search}`,
},
});
}

View File

@ -4,6 +4,7 @@ import { useRouter } from "next/router";
import { FormProvider, SubmitHandler, useForm } from "react-hook-form";
import { asStringOrNull } from "@lib/asStringOrNull";
import { BASE_URL } from "@lib/config/constants";
import { useLocale } from "@lib/hooks/useLocale";
import prisma from "@lib/prisma";
import { isSAMLLoginEnabled } from "@lib/saml";
@ -56,7 +57,12 @@ export default function Signup({ email }: Props) {
method: "POST",
})
.then(handleErrors)
.then(async () => await signIn("Cal.com", { callbackUrl: (router.query.callbackUrl || "") as string }))
.then(
async () =>
await signIn("Cal.com", {
callbackUrl: (`${BASE_URL}/${router.query.callbackUrl}` || "") as string,
})
)
.catch((err) => {
methods.setError("apiError", { message: err.message });
});
@ -123,7 +129,9 @@ export default function Signup({ email }: Props) {
color="secondary"
className="w-5/12 justify-center"
onClick={() =>
signIn("Cal.com", { callbackUrl: (router.query.callbackUrl || "") as string })
signIn("Cal.com", {
callbackUrl: (`${BASE_URL}/${router.query.callbackUrl}` || "") as string,
})
}>
{t("login_instead")}
</Button>
@ -176,7 +184,7 @@ export const getServerSideProps = async (ctx: GetServerSidePropsContext) => {
return {
redirect: {
permanent: false,
destination: "/auth/login?callbackUrl=" + ctx.query.callbackUrl,
destination: "/auth/login?callbackUrl=" + `${BASE_URL}/${ctx.query.callbackUrl}`,
},
};
}