feat: secu migrate to user uuid
This commit is contained in:
@@ -7,18 +7,18 @@ const COOKIE_NAME = "peakSkills_userId";
|
||||
|
||||
export async function PUT(request: NextRequest) {
|
||||
try {
|
||||
// Récupérer l'utilisateur depuis le cookie
|
||||
// Récupérer l'utilisateur depuis le cookie (maintenant un UUID)
|
||||
const cookieStore = await cookies();
|
||||
const userId = cookieStore.get(COOKIE_NAME)?.value;
|
||||
const userUuid = cookieStore.get(COOKIE_NAME)?.value;
|
||||
|
||||
if (!userId) {
|
||||
if (!userUuid) {
|
||||
return NextResponse.json(
|
||||
{ error: "Utilisateur non authentifié" },
|
||||
{ status: 401 }
|
||||
);
|
||||
}
|
||||
|
||||
const userProfile = await evaluationService.getUserById(parseInt(userId));
|
||||
const userProfile = await evaluationService.getUserByUuid(userUuid);
|
||||
if (!userProfile) {
|
||||
return NextResponse.json(
|
||||
{ error: "Utilisateur introuvable" },
|
||||
@@ -44,7 +44,7 @@ export async function PUT(request: NextRequest) {
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
await evaluationService.updateSkillLevel(
|
||||
await evaluationService.updateSkillLevelUuid(
|
||||
userProfile,
|
||||
category,
|
||||
skillId,
|
||||
@@ -59,7 +59,7 @@ export async function PUT(request: NextRequest) {
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
await evaluationService.updateSkillMentorStatus(
|
||||
await evaluationService.updateSkillMentorStatusUuid(
|
||||
userProfile,
|
||||
category,
|
||||
skillId,
|
||||
@@ -74,7 +74,7 @@ export async function PUT(request: NextRequest) {
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
await evaluationService.updateSkillLearningStatus(
|
||||
await evaluationService.updateSkillLearningStatusUuid(
|
||||
userProfile,
|
||||
category,
|
||||
skillId,
|
||||
@@ -83,7 +83,7 @@ export async function PUT(request: NextRequest) {
|
||||
break;
|
||||
|
||||
case "addSkill":
|
||||
await evaluationService.addSkillToEvaluation(
|
||||
await evaluationService.addSkillToEvaluationUuid(
|
||||
userProfile,
|
||||
category,
|
||||
skillId
|
||||
@@ -91,7 +91,7 @@ export async function PUT(request: NextRequest) {
|
||||
break;
|
||||
|
||||
case "removeSkill":
|
||||
await evaluationService.removeSkillFromEvaluation(
|
||||
await evaluationService.removeSkillFromEvaluationUuid(
|
||||
userProfile,
|
||||
category,
|
||||
skillId
|
||||
|
||||
Reference in New Issue
Block a user