From 559c8c5c9c8fffc84192e8d61f9f988e047f5f1e Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Mon, 18 Jan 2021 16:12:11 +0100 Subject: [PATCH] Implemented function to delete all active sessions of an user --- flaschengeist/controller/sessionController.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/flaschengeist/controller/sessionController.py b/flaschengeist/controller/sessionController.py index 0737cd2..a3e08f8 100644 --- a/flaschengeist/controller/sessionController.py +++ b/flaschengeist/controller/sessionController.py @@ -92,6 +92,16 @@ def get_users_sessions(user): return Session.query.filter(Session._user == user) +def delete_sessions(user): + """Deletes all active sessions of a user + + Args: + user (User): User to delete all sessions for + """ + Session.query.filter(Session._user_id == user._id).delete() + db.session.commit() + + def delete_session(token: Session): """Deletes given Session