1
0
mirror of https://git.ngram.ca/OpenJam/rc-servers synced 2026-08-23 23:08:52 +00:00

Also respond with banned error code on first request to web services server

This commit is contained in:
NG (Graham)
2025-07-27 16:19:54 -04:00
parent 89b1db35ba
commit 233f6d3ad5
3 changed files with 22 additions and 7 deletions

View File

@@ -572,6 +572,10 @@ impl <C: Clone> super::User<C> for UserData {
self.perms.developer self.perms.developer
} }
fn is_banned(&self) -> bool {
self.perms.banned
}
async fn unlocked_parts(&self) -> Vec<u32> { async fn unlocked_parts(&self) -> Vec<u32> {
match self.db.user_aux_by_user_id_and_descriptor(self.account.id, oj_rc_database::schema::user_aux::Descriptor::UnlockedParts).await { 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)) => { Ok(Some(parts)) => {

View File

@@ -66,6 +66,7 @@ pub trait User<C>: ChatUser + LobbyUser + MultiplayerUser {
fn is_mod(&self) -> bool; fn is_mod(&self) -> bool;
fn is_admin(&self) -> bool; fn is_admin(&self) -> bool;
fn is_dev(&self) -> bool; fn is_dev(&self) -> bool;
fn is_banned(&self) -> bool;
async fn unlocked_parts(&self) -> Vec<u32>; async fn unlocked_parts(&self) -> Vec<u32>;
async fn selected_garage(&self) -> (String, u32); async fn selected_garage(&self) -> (String, u32);
async fn select_garage(&self, slot: i32) -> Result<(), i16>; async fn select_garage(&self, slot: i32) -> Result<(), i16>;

View File

@@ -16,14 +16,24 @@ impl <C: Send + 'static> Operation<C> for MoreLobbyAuth {
if let Some(Typed::Str(auth_payload)) = params_dict.get(&Self::AUTH_PAYLOAD_KEY) { if let Some(Typed::Str(auth_payload)) = params_dict.get(&Self::AUTH_PAYLOAD_KEY) {
//let mut write_lock = user.write().unwrap(); //let mut write_lock = user.write().unwrap();
if user.update_with_auth(&auth_payload.string).await { if user.update_with_auth(&auth_payload.string).await {
let mut resp_params = std::collections::HashMap::new(); if user.user().unwrap().is_banned() {
resp_params.insert(Self::AUTH_PAYLOAD_KEY, polariton::operation::Typed::Byte(0)); return polariton::operation::OperationResponse {
return polariton::operation::OperationResponse { code: Self::op_code(),
code: Self::op_code(), return_code: oj_rc_core::data::error_codes::WebServicesError::Banned as i16,
return_code: 0, message: polariton::operation::Typed::Null,
message: polariton::operation::Typed::Null, params: polariton::operation::ParameterTable::with_capacity(0),
params: resp_params.into(), }
} 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 { polariton::operation::OperationResponse {