Redirect if user does not exist.

This commit is contained in:
charles-gauthereau
2024-11-13 19:45:22 +01:00
parent 12ff73c8e9
commit 9727eef581
6 changed files with 76 additions and 5 deletions
+9 -1
View File
@@ -5,12 +5,20 @@ import {SidebarInset, SidebarProvider} from "@/components/ui/sidebar"
import {AppSidebar} from "@/components/wrappers/Dashboard/SideBar/app-sidebar";
import {currentUser} from "@/auth/current-user";
import {Header} from "@/features/layout/Header";
import {prisma} from "@/prisma";
export default async function Layout({children}: { children: React.ReactNode }) {
const user = await currentUser()
if (!user) redirect('/login')
const userInfo = await prisma.user.findUnique({
where: {
email: user.email
}
})
if (!userInfo) redirect('/login')
return (
<SidebarProvider>