mirror of
https://github.com/documenso/documenso.git
synced 2025-11-14 08:42:12 +10:00
feat: add the admin page
This commit is contained in:
23
apps/web/src/app/(dashboard)/admin/layout.tsx
Normal file
23
apps/web/src/app/(dashboard)/admin/layout.tsx
Normal file
@ -0,0 +1,23 @@
|
||||
import { redirect } from 'next/navigation';
|
||||
|
||||
import { isAdmin } from '@documenso/lib/';
|
||||
import { getRequiredServerComponentSession } from '@documenso/lib/next-auth/get-server-session';
|
||||
|
||||
export type AdminLayoutProps = {
|
||||
children: React.ReactNode;
|
||||
};
|
||||
|
||||
export default async function AdminLayout({ children }: AdminLayoutProps) {
|
||||
const user = await getRequiredServerComponentSession();
|
||||
const isUserAdmin = isAdmin(user);
|
||||
|
||||
if (!user) {
|
||||
redirect('/signin');
|
||||
}
|
||||
|
||||
if (!isUserAdmin) {
|
||||
redirect('/dashboard');
|
||||
}
|
||||
|
||||
return <main className="mt-8 pb-8 md:mt-12 md:pb-12">{children}</main>;
|
||||
}
|
||||
Reference in New Issue
Block a user