feat(ST-nma6ylbl): requireAdmin() guard + /admin layout-shell + tests
- lib/auth-guard.ts: requireAdmin() toegevoegd — redirect /dashboard bij !userId of !isAdmin - app/(app)/admin/layout.tsx: admin-sidebar met links naar /admin/users, /admin/jobs, /admin/products - app/(app)/admin/page.tsx: redirect-stub naar /admin/users - __tests__/lib/auth-guard.test.ts: 3 tests voor requireAdmin() (geen userId, isAdmin=false, isAdmin=true)
This commit is contained in:
parent
8af5354f22
commit
c0ded1f482
4 changed files with 64 additions and 0 deletions
16
app/(app)/admin/layout.tsx
Normal file
16
app/(app)/admin/layout.tsx
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
import { requireAdmin } from '@/lib/auth-guard'
|
||||
import Link from 'next/link'
|
||||
|
||||
export default async function AdminLayout({ children }: { children: React.ReactNode }) {
|
||||
await requireAdmin()
|
||||
return (
|
||||
<div className="flex min-h-screen">
|
||||
<nav className="w-48 border-r p-4 flex flex-col gap-2">
|
||||
<Link href="/admin/users">Gebruikers</Link>
|
||||
<Link href="/admin/jobs">Claude Jobs</Link>
|
||||
<Link href="/admin/products">Producten</Link>
|
||||
</nav>
|
||||
<main className="flex-1 p-6">{children}</main>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
5
app/(app)/admin/page.tsx
Normal file
5
app/(app)/admin/page.tsx
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
import { redirect } from 'next/navigation'
|
||||
|
||||
export default function AdminPage() {
|
||||
redirect('/admin/users')
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue