From 86cf8feb550319c35217e4d9e74b2be45e3519af Mon Sep 17 00:00:00 2001 From: Benny Joo Date: Wed, 4 Sep 2024 09:05:38 -0400 Subject: [PATCH] chore: App-router-migration `/auth/new` and `/auth/saml-idp` (#16447) * auth/new: add to app router * auth/saml-idp: add to app router * fix --- apps/web/app/future/auth/new/page.tsx | 5 ++++ apps/web/app/future/auth/saml-idp/page.tsx | 1 + .../modules/auth/saml-idp/saml-idp-view.tsx | 23 +++++++++++++++++++ apps/web/pages/auth/saml-idp.tsx | 22 +----------------- 4 files changed, 30 insertions(+), 21 deletions(-) create mode 100644 apps/web/app/future/auth/new/page.tsx create mode 100644 apps/web/app/future/auth/saml-idp/page.tsx create mode 100644 apps/web/modules/auth/saml-idp/saml-idp-view.tsx diff --git a/apps/web/app/future/auth/new/page.tsx b/apps/web/app/future/auth/new/page.tsx new file mode 100644 index 0000000000..87df23a99f --- /dev/null +++ b/apps/web/app/future/auth/new/page.tsx @@ -0,0 +1,5 @@ +import { redirect } from "next/navigation"; + +export default function Page() { + redirect(process.env.NEXT_PUBLIC_WEBAPP_URL || "https://app.cal.com"); +} diff --git a/apps/web/app/future/auth/saml-idp/page.tsx b/apps/web/app/future/auth/saml-idp/page.tsx new file mode 100644 index 0000000000..02911d67e0 --- /dev/null +++ b/apps/web/app/future/auth/saml-idp/page.tsx @@ -0,0 +1 @@ +export { default } from "~/auth/saml-idp/saml-idp-view"; diff --git a/apps/web/modules/auth/saml-idp/saml-idp-view.tsx b/apps/web/modules/auth/saml-idp/saml-idp-view.tsx new file mode 100644 index 0000000000..975e465877 --- /dev/null +++ b/apps/web/modules/auth/saml-idp/saml-idp-view.tsx @@ -0,0 +1,23 @@ +"use client"; + +import { signIn } from "next-auth/react"; +import { useEffect } from "react"; + +import { useCompatSearchParams } from "@calcom/lib/hooks/useCompatSearchParams"; + +// To handle the IdP initiated login flow callback +export default function SamlIdp() { + const searchParams = useCompatSearchParams(); + + useEffect(() => { + const code = searchParams?.get("code"); + + signIn("saml-idp", { + callbackUrl: "/", + code, + }); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); + + return null; +} diff --git a/apps/web/pages/auth/saml-idp.tsx b/apps/web/pages/auth/saml-idp.tsx index 661980fa68..02911d67e0 100644 --- a/apps/web/pages/auth/saml-idp.tsx +++ b/apps/web/pages/auth/saml-idp.tsx @@ -1,21 +1 @@ -import { signIn } from "next-auth/react"; -import { useEffect } from "react"; - -import { useCompatSearchParams } from "@calcom/lib/hooks/useCompatSearchParams"; - -// To handle the IdP initiated login flow callback -export default function Page() { - const searchParams = useCompatSearchParams(); - - useEffect(() => { - const code = searchParams?.get("code"); - - signIn("saml-idp", { - callbackUrl: "/", - code, - }); - // eslint-disable-next-line react-hooks/exhaustive-deps - }, []); - - return null; -} +export { default } from "~/auth/saml-idp/saml-idp-view";