From 4d6a73fa99d643623e22cee1c4d09e39630d4620 Mon Sep 17 00:00:00 2001 From: crthpl Date: Mon, 13 Apr 2026 16:01:55 -0700 Subject: [PATCH] Add admins to cohort member list on access (ARB-510) When an admin connects to a cohort via WebSocket, they should be automatically added to the global cohort_member table if they're not already a member. This ensures the admin cohort member list accurately reflects who has accessed the cohort. Previously, admins were allowed to access any cohort due to the is_admin authorization check, but they were never added to the cohort member list. Now, after authentication, we ensure admins are added as members of the cohort they're accessing. --- backend/src/handle_socket.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/backend/src/handle_socket.rs b/backend/src/handle_socket.rs index 4997092e..999ab7f7 100644 --- a/backend/src/handle_socket.rs +++ b/backend/src/handle_socket.rs @@ -1312,6 +1312,18 @@ async fn authenticate( } } + // Admins always get added to the cohort member list when they access + if is_admin && !is_member { + if let Err(e) = global_db + .add_member_by_user_id(cohort.info.id, global_user.id, None) + .await + { + tracing::warn!("Failed to add admin as cohort member: {e}"); + } else { + is_member = true; + } + } + let mut auction_only = false; if !is_admin && !is_member {