From 2741e3ae5e65e21d5105c2ca68c33f1ffd53c744 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Valentin=20Mogu=C3=A9rou?= Date: Mon, 15 May 2023 06:19:11 +0200 Subject: [PATCH] =?UTF-8?q?Combiner=20la=20suppression=20des=20sessions=20?= =?UTF-8?q?obsol=C3=A8tes=20et=20la=20v=C3=A9rification=20de=20la=20connex?= =?UTF-8?q?ion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/database.py | 7 +------ app/views.py | 1 - 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/app/database.py b/app/database.py index 0c9c99b..90c9818 100644 --- a/app/database.py +++ b/app/database.py @@ -11,12 +11,6 @@ class Database: database=app.config["DB_DATABASE"] ) - def delete_old_sessions(self): - cursor = self.db.cursor() - cursor.execute("DELETE FROM sessions WHERE expiry_date <= CURRENT_TIMESTAMP") - self.db.commit() - cursor.close() - def create_session(self, username, password): cursor = self.db.cursor() cursor.execute("SELECT user_id FROM utilisateurs WHERE username=%s AND password=%s", (username, password)) @@ -40,6 +34,7 @@ class Database: def check_connection(self, uuid): cursor = self.db.cursor() + cursor.execute("DELETE FROM sessions WHERE expiry_date <= CURRENT_TIMESTAMP") cursor.execute("SELECT session_id FROM sessions WHERE session_id=%s", (uuid,)) result = cursor.fetchall() cursor.close() diff --git a/app/views.py b/app/views.py index 9c8e6b4..f9a5108 100644 --- a/app/views.py +++ b/app/views.py @@ -8,7 +8,6 @@ from .database import Session def views(app, db): def est_connecte(): - db.delete_old_sessions() return session.get("uuid") is not None and db.check_connection(session.get("uuid")) def login_required(func):