From d3426c1663d3a643c6ee92658b06cfb423152d83 Mon Sep 17 00:00:00 2001 From: Manus Date: Sat, 8 Aug 2026 10:41:01 +0000 Subject: [PATCH] =?UTF-8?q?Checkpoint:=20Correction=20de=20l'erreur=20"non?= =?UTF-8?q?=20authentifi=C3=A9"=20sur=20/api/db-backup=20:=20utilisation?= =?UTF-8?q?=20de=20parseCookies(req.headers.cookie)=20au=20lieu=20de=20req?= =?UTF-8?q?.cookies=20(qui=20n=C3=A9cessitait=20cookie-parser=20non=20inst?= =?UTF-8?q?all=C3=A9).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/_core/index.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/server/_core/index.ts b/server/_core/index.ts index 529c79c..163c540 100644 --- a/server/_core/index.ts +++ b/server/_core/index.ts @@ -7,6 +7,7 @@ import fs from "fs"; import archiver from "archiver"; import { exec as execCb } from "child_process"; import { promisify } from "util"; +import { parse as parseCookies } from "cookie"; const execAsync = promisify(execCb); import { createExpressMiddleware } from "@trpc/server/adapters/express"; import { registerOAuthRoutes } from "./oauth"; @@ -233,7 +234,8 @@ async function startServer() { app.post("/api/db-backup", async (req, res) => { // Vérifier l'auth JWT const { verifyToken } = await import("../auth"); - const token = req.cookies?.auth_token; + const cookies = parseCookies(req.headers.cookie || ""); + const token = cookies.auth_token; if (!token) { res.status(401).json({ error: "Non authentifié" }); return; } const user = verifyToken(token); if (!user || user.role !== "admin") { res.status(403).json({ error: "Accès réservé aux admins" }); return; } @@ -278,7 +280,8 @@ async function startServer() { // Télécharger une sauvegarde existante app.get("/api/db-backup/:filename", async (req, res) => { const { verifyToken } = await import("../auth"); - const token = req.cookies?.auth_token; + const cookies2 = parseCookies(req.headers.cookie || ""); + const token = cookies2.auth_token; if (!token) { res.status(401).json({ error: "Non authentifié" }); return; } const user = verifyToken(token); if (!user || user.role !== "admin") { res.status(403).json({ error: "Accès réservé aux admins" }); return; }