From df0a5226561eebf9ff6ff1566feb3e80fc736c86 Mon Sep 17 00:00:00 2001 From: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com> Date: Sat, 17 Dec 2022 02:10:20 +0530 Subject: [PATCH] fix: use callback url in signup (#6010) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: use callback url in signup Signed-off-by: Udit Takkar * fix: do login after sign up and redirect to onboarding Signed-off-by: Udit Takkar * chore: add telemetry Signed-off-by: Udit Takkar * fix: error handling Signed-off-by: Udit Takkar Signed-off-by: Udit Takkar Co-authored-by: Peer Richelsen Co-authored-by: Omar López --- apps/web/pages/signup.tsx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/apps/web/pages/signup.tsx b/apps/web/pages/signup.tsx index 183fc9414c..1b8c77623c 100644 --- a/apps/web/pages/signup.tsx +++ b/apps/web/pages/signup.tsx @@ -6,6 +6,7 @@ import { FormProvider, SubmitHandler, useForm } from "react-hook-form"; import LicenseRequired from "@calcom/features/ee/common/components/v2/LicenseRequired"; import { isSAMLLoginEnabled } from "@calcom/features/ee/sso/lib/saml"; import { useLocale } from "@calcom/lib/hooks/useLocale"; +import { collectPageParameters, telemetryEventTypes, useTelemetry } from "@calcom/lib/telemetry"; import { inferSSRProps } from "@calcom/types/inferSSRProps"; import { Alert, Button, EmailField, PasswordField, TextField } from "@calcom/ui"; import { HeadSeo } from "@calcom/web/components/seo/head-seo"; @@ -26,6 +27,8 @@ type FormValues = { export default function Signup({ prepopulateFormValues }: inferSSRProps) { const { t } = useLocale(); const router = useRouter(); + const telemetry = useTelemetry(); + const methods = useForm({ defaultValues: prepopulateFormValues, }); @@ -53,8 +56,12 @@ export default function Signup({ prepopulateFormValues }: inferSSRProps { - await signIn("Cal.com", { - callbackUrl: router.query.callbackUrl ? `${WEBAPP_URL}/${router.query.callbackUrl}` : WEBAPP_URL, + telemetry.event(telemetryEventTypes.login, collectPageParameters()); + await signIn<"credentials">("credentials", { + ...data, + callbackUrl: router.query.callbackUrl + ? `${WEBAPP_URL}/${router.query.callbackUrl}` + : `${WEBAPP_URL}/getting-started`, }); }) .catch((err) => { @@ -111,7 +118,9 @@ export default function Signup({ prepopulateFormValues }: inferSSRProps signIn("Cal.com", { - callbackUrl: (`${WEBAPP_URL}/${router.query.callbackUrl}` || "") as string, + callbackUrl: router.query.callbackUrl + ? `${WEBAPP_URL}/${router.query.callbackUrl}` + : `${WEBAPP_URL}/getting-started`, }) }> {t("login_instead")}