Initial commit - SaveTheMoment Atlas Basis-Setup
This commit is contained in:
21
app/driver/layout.tsx
Normal file
21
app/driver/layout.tsx
Normal file
@@ -0,0 +1,21 @@
|
||||
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}</>;
|
||||
}
|
||||
Reference in New Issue
Block a user