refactor: auth service for logic in evaluation skill PUT
This commit is contained in:
@@ -1,30 +1,11 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { cookies } from "next/headers";
|
||||
import { AuthService } from "@/services/auth-service";
|
||||
import { evaluationService } from "@/services/evaluation-service";
|
||||
import { userService } from "@/services/user-service";
|
||||
|
||||
const COOKIE_NAME = "peakSkills_userId";
|
||||
|
||||
export async function PUT(request: NextRequest) {
|
||||
try {
|
||||
// Récupérer l'utilisateur depuis le cookie (maintenant un UUID)
|
||||
const cookieStore = await cookies();
|
||||
const userUuid = cookieStore.get(COOKIE_NAME)?.value;
|
||||
|
||||
if (!userUuid) {
|
||||
return NextResponse.json(
|
||||
{ error: "Utilisateur non authentifié" },
|
||||
{ status: 401 }
|
||||
);
|
||||
}
|
||||
|
||||
const userProfile = await userService.getUserByUuid(userUuid);
|
||||
if (!userProfile) {
|
||||
return NextResponse.json(
|
||||
{ error: "Utilisateur introuvable" },
|
||||
{ status: 404 }
|
||||
);
|
||||
}
|
||||
const { userProfile } = await AuthService.requireAuthenticatedUser();
|
||||
|
||||
const body = await request.json();
|
||||
const { category, skillId, level, canMentor, wantsToLearn, action } = body;
|
||||
|
||||
Reference in New Issue
Block a user