Files
Atlas/app/dashboard/layout.tsx
2025-11-12 20:21:32 +01:00

22 lines
432 B
TypeScript

import { getServerSession } from 'next-auth';
import { redirect } from 'next/navigation';
import { authOptions } from '@/lib/auth';
export default async function DashboardLayout({
children,
}: {
children: React.ReactNode;
}) {
const session = await getServerSession(authOptions);
if (!session) {
redirect('/login');
}
if (session.user.role !== 'ADMIN') {
redirect('/driver');
}
return <>{children}</>;
}