beta : essayer chaque cookie jrb_s reçu (ancien cookie qui masquait la session)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Cette révision appartient à :
1 Parent
3645a80139
révision
5ceed17620
1 fichier modifié
+9
-6
@@ -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)
|
||||
|
||||
Référencer dans un nouveau ticket
Bloquer un utilisateur