From 5ceed1762026538ad02aad51e1d657539a09f80e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Gastinel?= <264859180+gastinelt@users.noreply.github.com> Date: Sat, 31 Oct 2026 14:37:56 +0100 Subject: [PATCH] =?UTF-8?q?beta=20:=20essayer=20chaque=20cookie=20jrb=5Fs?= =?UTF-8?q?=20re=C3=A7u=20(ancien=20cookie=20qui=20masquait=20la=20session?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- beta/server.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/beta/server.py b/beta/server.py index 42de3ca..6944015 100644 --- a/beta/server.py +++ b/beta/server.py @@ -195,13 +195,16 @@ class Handler(BaseHTTPRequestHandler): def session(self): brut = self.headers.get("Cookie", "") - try: - tok = cookies.SimpleCookie(brut)[COOKIE].value - except Exception: - return None - h = hashlib.sha256(tok.encode()).hexdigest() + # Le navigateur peut envoyer plusieurs jrb_s (ancien cookie resté sur un autre chemin ou domaine) : + # SimpleCookie n'en garde qu'un, on les essaie donc tous. + jetons = [m.strip()[len(COOKIE) + 1:] for m in brut.split(";") if m.strip().startswith(COOKIE + "=")] now = time.time() - s = self.c.execute("SELECT * FROM sessions WHERE token_hash=? AND expires_at>?", (h, now)).fetchone() + s = None + for tok in jetons[:5]: + h = hashlib.sha256(tok.encode()).hexdigest() + s = self.c.execute("SELECT * FROM sessions WHERE token_hash=? AND expires_at>?", (h, now)).fetchone() + if s: + break if not s: return None # Cas 1 : session testeur direct (inscription libre)