From 741f2608b0fb28f819f3bebb5ba07c545259e51c Mon Sep 17 00:00:00 2001 From: gibbyb Date: Sat, 28 Mar 2026 16:06:36 -0500 Subject: [PATCH] Add auth redirect to site admin page --- apps/next/src/app/(payload)/admin/layout.tsx | 27 ++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 apps/next/src/app/(payload)/admin/layout.tsx diff --git a/apps/next/src/app/(payload)/admin/layout.tsx b/apps/next/src/app/(payload)/admin/layout.tsx new file mode 100644 index 0000000..4fe0681 --- /dev/null +++ b/apps/next/src/app/(payload)/admin/layout.tsx @@ -0,0 +1,27 @@ +import type { Metadata } from 'next'; +import { redirect } from 'next/navigation'; +import { isAuthenticatedNextjs } from '@convex-dev/auth/nextjs/server'; + +export const generateMetadata = (): Metadata => { + return { + title: 'Site Admin', + robots: { + index: false, + follow: false, + googleBot: { + index: false, + follow: false, + }, + }, + }; +}; + +const AdminLayout = async ({ + children, +}: Readonly<{ children: React.ReactNode }>) => { + if (!(await isAuthenticatedNextjs())) { + redirect('/sign-in'); + } + return <>{children}; +}; +export default AdminLayout;