Skip to content

Commit

Permalink
Fixed Logout
Browse files Browse the repository at this point in the history
Logout wasn't correctly deleting blackboard sessions
  • Loading branch information
TheManWhoLikesToCode committed Jan 24, 2024
1 parent 3964ddf commit b962ef4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion backend/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def logout():
user_session = request.cookies.get('user_session')
if user_session:
# Remove the session from BlackboardSessionManager
bb_session_manager.delete_bb_session(user_session)
bb_session_manager.delete_bb_session_by_id(user_session)

# Clear the user's session cookie
resp = make_response(jsonify({'message': 'Logged out successfully'}))
Expand Down
13 changes: 12 additions & 1 deletion backend/blackboard_session_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,18 @@ def delete_bb_session(self, username):
with self.lock:
session_id = self.user_session_map.pop(username, None)
if session_id:
return self.bb_sessions.pop(session_id, None)
del self.bb_sessions[session_id]
return True
return False

def delete_bb_session_by_id(self, session_id):
with self.lock:
for user, sid in self.user_session_map.items():
if sid == session_id:
del self.user_session_map[user]
del self.bb_sessions[session_id]
return True
return False

def clean_up_inactive_sessions(self, inactivity_threshold_seconds=3600):
with self.lock:
Expand Down
5 changes: 4 additions & 1 deletion backend/features/environment.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from app import app

def before_all(context):
context.client = app.test_client()
context.client = app.test_client()

def after_scenario(context, scenario):
context.client.post('/logout')

0 comments on commit b962ef4

Please sign in to comment.