Add auth redirect to site admin page
This commit is contained in:
27
apps/next/src/app/(payload)/admin/layout.tsx
Normal file
27
apps/next/src/app/(payload)/admin/layout.tsx
Normal file
@@ -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;
|
||||||
Reference in New Issue
Block a user