Skip to content

Commit 4d0458b

Browse files
feat: add client-side auth protection to routing forms pages (calcom#23743)
* feat: add client-side auth protection to routing forms pages - Create RoutingFormsShell component with useRedirectToLoginIfUnauthenticated hook - Wrap form-edit, route-builder, and incomplete-booking pages with RoutingFormsShell - Ensures consistent auth behavior during client-side navigation - Maintains existing server-side auth protection - Fix ESLint warnings: replace 'any' types with 'unknown' types and add eslint-disable for restricted imports Co-Authored-By: eunjae@cal.com <hey@eunjae.dev> * refactor: clean up RoutingFormsShell implementation - Remove unused isPublic parameter from RoutingFormsShell component - Keep only essential client-side authentication protection functionality - Fix remaining ESLint warnings to allow commit to pass Co-Authored-By: eunjae@cal.com <hey@eunjae.dev> * remove unnecessary hook * use shell at layout * rename component --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
1 parent 55e6682 commit 4d0458b

2 files changed

Lines changed: 26 additions & 2 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
"use client";
2+
3+
import { useRedirectToLoginIfUnauthenticated } from "@calcom/features/auth/lib/hooks/useRedirectToLoginIfUnauthenticated";
4+
5+
export function RoutingFormAuthGuard({ children }: { children: React.ReactNode }) {
6+
useRedirectToLoginIfUnauthenticated();
7+
8+
return <>{children}</>;
9+
}
Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,22 @@
11
import type { ReactNode } from "react";
22

33
import FormProvider from "./FormProvider";
4+
import { RoutingFormAuthGuard } from "./RoutingFormAuthGuard";
45

5-
export default async function Layout({ children }: { children: ReactNode }) {
6-
return <FormProvider>{children}</FormProvider>;
6+
interface LayoutProps {
7+
children: ReactNode;
8+
params: { pages: string[] };
9+
}
10+
11+
export default async function Layout({ children, params }: LayoutProps) {
12+
const isPublic = params.pages?.[0] === "routing-link";
13+
if (isPublic) {
14+
return <FormProvider>{children}</FormProvider>;
15+
}
16+
17+
return (
18+
<RoutingFormAuthGuard>
19+
<FormProvider>{children}</FormProvider>
20+
</RoutingFormAuthGuard>
21+
);
722
}

0 commit comments

Comments
 (0)