From 233f6d3ad50cb268ee69f52f2a2b7b0419174c4a Mon Sep 17 00:00:00 2001 From: "NG (Graham)" Date: Sun, 27 Jul 2025 16:19:54 -0400 Subject: [PATCH] Also respond with banned error code on first request to web services server --- rc_core/src/persist/user/account_json.rs | 4 ++++ rc_core/src/persist/user/traits.rs | 1 + rc_services_room/src/operations/more_auth.rs | 24 ++++++++++++++------ 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/rc_core/src/persist/user/account_json.rs b/rc_core/src/persist/user/account_json.rs index 6388114..015f3de 100644 --- a/rc_core/src/persist/user/account_json.rs +++ b/rc_core/src/persist/user/account_json.rs @@ -572,6 +572,10 @@ impl super::User for UserData { self.perms.developer } + fn is_banned(&self) -> bool { + self.perms.banned + } + async fn unlocked_parts(&self) -> Vec { match self.db.user_aux_by_user_id_and_descriptor(self.account.id, oj_rc_database::schema::user_aux::Descriptor::UnlockedParts).await { Ok(Some(parts)) => { diff --git a/rc_core/src/persist/user/traits.rs b/rc_core/src/persist/user/traits.rs index 3cf37e4..91b7e4f 100644 --- a/rc_core/src/persist/user/traits.rs +++ b/rc_core/src/persist/user/traits.rs @@ -66,6 +66,7 @@ pub trait User: ChatUser + LobbyUser + MultiplayerUser { fn is_mod(&self) -> bool; fn is_admin(&self) -> bool; fn is_dev(&self) -> bool; + fn is_banned(&self) -> bool; async fn unlocked_parts(&self) -> Vec; async fn selected_garage(&self) -> (String, u32); async fn select_garage(&self, slot: i32) -> Result<(), i16>; diff --git a/rc_services_room/src/operations/more_auth.rs b/rc_services_room/src/operations/more_auth.rs index 3140dc0..a8c6081 100644 --- a/rc_services_room/src/operations/more_auth.rs +++ b/rc_services_room/src/operations/more_auth.rs @@ -16,14 +16,24 @@ impl Operation for MoreLobbyAuth { if let Some(Typed::Str(auth_payload)) = params_dict.get(&Self::AUTH_PAYLOAD_KEY) { //let mut write_lock = user.write().unwrap(); if user.update_with_auth(&auth_payload.string).await { - let mut resp_params = std::collections::HashMap::new(); - resp_params.insert(Self::AUTH_PAYLOAD_KEY, polariton::operation::Typed::Byte(0)); - return polariton::operation::OperationResponse { - code: Self::op_code(), - return_code: 0, - message: polariton::operation::Typed::Null, - params: resp_params.into(), + if user.user().unwrap().is_banned() { + return polariton::operation::OperationResponse { + code: Self::op_code(), + return_code: oj_rc_core::data::error_codes::WebServicesError::Banned as i16, + message: polariton::operation::Typed::Null, + params: polariton::operation::ParameterTable::with_capacity(0), + } + } else { + let mut resp_params = std::collections::HashMap::with_capacity(1); + resp_params.insert(Self::AUTH_PAYLOAD_KEY, polariton::operation::Typed::Byte(0)); + return polariton::operation::OperationResponse { + code: Self::op_code(), + return_code: 0, + message: polariton::operation::Typed::Null, + params: resp_params.into(), + } } + } } polariton::operation::OperationResponse {