diff --git a/apps/web/app/(use-page-wrapper)/apps/routing-forms/[...pages]/RoutingFormAuthGuard.tsx b/apps/web/app/(use-page-wrapper)/apps/routing-forms/[...pages]/RoutingFormAuthGuard.tsx new file mode 100644 index 0000000000..a6bb3b04ad --- /dev/null +++ b/apps/web/app/(use-page-wrapper)/apps/routing-forms/[...pages]/RoutingFormAuthGuard.tsx @@ -0,0 +1,9 @@ +"use client"; + +import { useRedirectToLoginIfUnauthenticated } from "@calcom/features/auth/lib/hooks/useRedirectToLoginIfUnauthenticated"; + +export function RoutingFormAuthGuard({ children }: { children: React.ReactNode }) { + useRedirectToLoginIfUnauthenticated(); + + return <>{children}; +} diff --git a/apps/web/app/(use-page-wrapper)/apps/routing-forms/[...pages]/layout.tsx b/apps/web/app/(use-page-wrapper)/apps/routing-forms/[...pages]/layout.tsx index a31b1251b4..22594d160a 100644 --- a/apps/web/app/(use-page-wrapper)/apps/routing-forms/[...pages]/layout.tsx +++ b/apps/web/app/(use-page-wrapper)/apps/routing-forms/[...pages]/layout.tsx @@ -1,7 +1,22 @@ import type { ReactNode } from "react"; import FormProvider from "./FormProvider"; +import { RoutingFormAuthGuard } from "./RoutingFormAuthGuard"; -export default async function Layout({ children }: { children: ReactNode }) { - return {children}; +interface LayoutProps { + children: ReactNode; + params: { pages: string[] }; +} + +export default async function Layout({ children, params }: LayoutProps) { + const isPublic = params.pages?.[0] === "routing-link"; + if (isPublic) { + return {children}; + } + + return ( + + {children} + + ); }