feat: add admin dashboard and core API routes with Docker configuration

This commit is contained in:
2026-10-29 19:46:37 +01:00
parent 2fdabe1dfd
commit 4f4856d9dc
89 changed files with 1984 additions and 1034 deletions

View File

@@ -1,27 +1,25 @@
import { NextRequest, NextResponse } from 'next/server';
import prisma from '@/lib/prisma';
import { getAuthUser, USER_SAFE_SELECT } from '@/lib/auth-utils';
export async function GET(request: NextRequest) {
const { searchParams } = new URL(request.url);
const email = searchParams.get('email');
const authUser = await getAuthUser(request);
if (!authUser) {
return NextResponse.json({ error: 'Authentification requise' }, { status: 401 });
}
if (!email) {
return NextResponse.json({ error: 'Email requis' }, { status: 400 });
const { searchParams } = new URL(request.url);
const email = searchParams.get('email')?.toLowerCase().trim() || authUser.email.toLowerCase();
// Seul l'utilisateur lui-même ou un administrateur peut consulter ce profil par email
if (authUser.role !== 'ADMIN' && authUser.email.toLowerCase() !== email) {
return NextResponse.json({ error: 'Accès non autorisé' }, { status: 403 });
}
try {
const user = await prisma.user.findUnique({
where: { email },
select: {
id: true,
name: true,
email: true,
role: true,
avatar: true,
phone: true,
bio: true,
location: true
}
select: USER_SAFE_SELECT
});
if (!user) {