Combiner la suppression des sessions obsolètes et la vérification de la connexion
This commit is contained in:
parent
861ae7245c
commit
2741e3ae5e
@ -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()
|
||||
|
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user