fix: admin-navigatie zichtbaar voor ADMIN-rol gebruikers
- requireAdmin() checkt nu de database i.p.v. session.isAdmin (was altijd undefined)
- loginAction stelt session.isAdmin in op basis van UserRole in de DB
- registerAction stelt session.isAdmin = false expliciet in
- NavBar toont 'Admin'-link conditioneel als roles.includes('ADMIN')
- UserMenu ROLE_LABELS uitgebreid met ADMIN → 'Admin'
- Tests aangepast: prismaUserRole.findFirst mock toegevoegd
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
c3f10cccce
commit
fbf58d4e44
6 changed files with 26 additions and 2 deletions
|
|
@ -3,10 +3,14 @@ import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
|
|||
const getSessionMock = vi.fn()
|
||||
const isPairedSessionExpiredMock = vi.fn()
|
||||
const redirectMock = vi.fn(() => { throw new Error('REDIRECT_CALLED') })
|
||||
const prismaUserRoleFindFirstMock = vi.fn()
|
||||
|
||||
vi.mock('@/lib/auth', () => ({ getSession: getSessionMock }))
|
||||
vi.mock('@/lib/auth/pairing', () => ({ isPairedSessionExpired: isPairedSessionExpiredMock }))
|
||||
vi.mock('next/navigation', () => ({ redirect: redirectMock }))
|
||||
vi.mock('@/lib/prisma', () => ({
|
||||
prisma: { userRole: { findFirst: prismaUserRoleFindFirstMock } },
|
||||
}))
|
||||
|
||||
describe('requireSession', () => {
|
||||
beforeEach(() => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue