diff --git a/src/auth/actor.rs b/src/auth/actor.rs index d44802f..fb2694a 100644 --- a/src/auth/actor.rs +++ b/src/auth/actor.rs @@ -15,7 +15,7 @@ pub(crate) enum AuthActorMessage { ip: String, // Oneshot response - tx: oneshot::Sender, + tx: oneshot::Sender, }, } @@ -47,8 +47,8 @@ impl AuthActor { &mut self, session_token: String, ip: String, - ) -> result::Result { - let request_json = types::AuthRequest { + ) -> result::Result { + let request_json = types::AuthJoinBody { secret_key: self.secret_key.clone(), session_token: session_token, ip: ip, @@ -64,7 +64,7 @@ impl AuthActor { // TODO: Convert JSON error to result::Error arm at some point so that we can match for those errors later >_< // also it's just a good idea - let deserialized_response = raw_response.json::().await?; + let deserialized_response = raw_response.json::().await?; Ok(deserialized_response) } diff --git a/src/auth/client.rs b/src/auth/client.rs index 433da64..f6823f0 100644 --- a/src/auth/client.rs +++ b/src/auth/client.rs @@ -10,8 +10,8 @@ pub struct Client { impl Client { /// Creates a new auth client. - /// [auth_url] is the base URL path to the cvmauth backend. - /// [secret_key] is the given secret key. + /// `auth_url` is the base URL path to the cvmauth server to use. + /// `secret_key` is the given secret key for said server. /// /// # Example /// ```rust @@ -37,7 +37,7 @@ impl Client { &self, token: String, ip: String, - ) -> result::Result { + ) -> result::Result { let (tx, rx) = oneshot::channel(); let _ = self @@ -50,7 +50,6 @@ impl Client { .await; match rx.await { - // TODO: Convert JSON failures to an error. Ok(res) => Ok(res), // See above FIXME Err(_err) => Err(result::Error::GeneralFail), diff --git a/src/auth/types.rs b/src/auth/types.rs index ba6a9ec..745bc96 100644 --- a/src/auth/types.rs +++ b/src/auth/types.rs @@ -2,7 +2,7 @@ use crate::user_types::Rank; use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize, Debug)] -pub struct AuthRequest { +pub struct AuthJoinBody { #[serde(rename = "secretKey")] pub secret_key: String, @@ -13,11 +13,15 @@ pub struct AuthRequest { } #[derive(Deserialize, Debug)] -pub struct AuthResponse { +pub struct AuthJoinResponse { pub success: bool, #[serde(rename = "clientSuccess")] pub client_sucess: bool, pub username: Option, pub error: Option, pub rank: Rank, + + pub banned: Option, + #[serde(rename = "banReason")] + pub ban_reason: Option }