feat(auth): add role guards and protect admin routes

This commit is contained in:
2026-06-04 21:57:39 +02:00
parent 601dea9526
commit 12cbec92a0
8 changed files with 114 additions and 27 deletions
+4 -1
View File
@@ -3,15 +3,18 @@ import { Toaster } from "sonner"
import Navbar from "@/components/layout/navbar"
import AppSidebar from "@/components/layout/sidebar"
import { SidebarProvider } from "@/components/ui/sidebar"
import { auth } from "@/lib/auth"
export default async function LayoutDashboard({
children,
}: {
children: React.ReactNode
}) {
const session = await auth()
return (
<SidebarProvider>
<AppSidebar />
<AppSidebar userRole={session?.user.role} />
<main className="w-full">
<Navbar />
<div className="flex-1 p-6">{children}</div>
+11
View File
@@ -0,0 +1,11 @@
import Link from "next/link"
export default function ForbiddenPage() {
return (
<main>
<h1>Acceso denegado</h1>
<p>No tienes permisos para acceder a esta sección.</p>
<Link href="/">Volver al inicio</Link>
</main>
)
}