22 lines
440 B
TypeScript
22 lines
440 B
TypeScript
import { getServerSession } from 'next-auth';
|
|
import { redirect } from 'next/navigation';
|
|
import { authOptions } from '@/lib/auth';
|
|
|
|
export default async function DriverLayout({
|
|
children,
|
|
}: {
|
|
children: React.ReactNode;
|
|
}) {
|
|
const session = await getServerSession(authOptions);
|
|
|
|
if (!session) {
|
|
redirect('/driver-login');
|
|
}
|
|
|
|
if (session.user.role !== 'DRIVER') {
|
|
redirect('/dashboard');
|
|
}
|
|
|
|
return <>{children}</>;
|
|
}
|