feat: add admin dashboard and core API routes with Docker configuration
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { NextRequest, NextResponse } from 'next/server'
|
||||
import prisma from '../../../../../lib/prisma'
|
||||
import { isAdmin } from '@/lib/auth-utils'
|
||||
|
||||
// PATCH /api/admin/reports/[id] — Update report status
|
||||
export async function PATCH(
|
||||
@@ -7,21 +8,10 @@ export async function PATCH(
|
||||
context: { params: Promise<{ id: string }> }
|
||||
): Promise<Response> {
|
||||
try {
|
||||
const userId = request.headers.get('x-user-id')
|
||||
const { id } = await context.params
|
||||
const { status } = await request.json()
|
||||
|
||||
if (!userId) {
|
||||
return NextResponse.json({ error: 'Utilisateur non identifié' }, { status: 401 })
|
||||
}
|
||||
|
||||
// Check if user is admin
|
||||
const user = await prisma.user.findUnique({
|
||||
where: { id: userId },
|
||||
select: { role: true }
|
||||
})
|
||||
|
||||
if (!user || user.role !== 'ADMIN') {
|
||||
if (!(await isAdmin(request))) {
|
||||
return NextResponse.json({ error: 'Accès réservé aux administrateurs' }, { status: 403 })
|
||||
}
|
||||
|
||||
|
||||
@@ -1,22 +1,11 @@
|
||||
import { NextRequest, NextResponse } from 'next/server'
|
||||
import prisma from '@/lib/prisma'
|
||||
import { isAdmin } from '@/lib/auth-utils'
|
||||
|
||||
// GET /api/admin/reports — List all reports for moderation
|
||||
export async function GET(request: NextRequest) {
|
||||
try {
|
||||
const userId = request.headers.get('x-user-id')
|
||||
|
||||
if (!userId) {
|
||||
return NextResponse.json({ error: 'Utilisateur non identifié' }, { status: 401 })
|
||||
}
|
||||
|
||||
// Check if user is admin
|
||||
const user = await prisma.user.findUnique({
|
||||
where: { id: userId },
|
||||
select: { role: true }
|
||||
})
|
||||
|
||||
if (!user || user.role !== 'ADMIN') {
|
||||
if (!(await isAdmin(request))) {
|
||||
return NextResponse.json({ error: 'Accès réservé aux administrateurs' }, { status: 403 })
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user