Implemented function to delete all active sessions of an user

This commit is contained in:
Ferdinand Thiessen 2021-01-18 16:12:11 +01:00
parent 23268f6557
commit 559c8c5c9c
1 changed files with 10 additions and 0 deletions

View File

@ -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