auth: add ban stuff to AuthJoinResponse

renames them just to be nice.
This commit is contained in:
Lily Tsuru 2024-05-10 07:17:03 -04:00
parent 37339e2580
commit 0bb73e1194
3 changed files with 13 additions and 10 deletions

View file

@ -15,7 +15,7 @@ pub(crate) enum AuthActorMessage {
ip: String, ip: String,
// Oneshot response // Oneshot response
tx: oneshot::Sender<types::AuthResponse>, tx: oneshot::Sender<types::AuthJoinResponse>,
}, },
} }
@ -47,8 +47,8 @@ impl AuthActor {
&mut self, &mut self,
session_token: String, session_token: String,
ip: String, ip: String,
) -> result::Result<types::AuthResponse> { ) -> result::Result<types::AuthJoinResponse> {
let request_json = types::AuthRequest { let request_json = types::AuthJoinBody {
secret_key: self.secret_key.clone(), secret_key: self.secret_key.clone(),
session_token: session_token, session_token: session_token,
ip: ip, 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 >_< // 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 // also it's just a good idea
let deserialized_response = raw_response.json::<types::AuthResponse>().await?; let deserialized_response = raw_response.json::<types::AuthJoinResponse>().await?;
Ok(deserialized_response) Ok(deserialized_response)
} }

View file

@ -10,8 +10,8 @@ pub struct Client {
impl Client { impl Client {
/// Creates a new auth client. /// Creates a new auth client.
/// [auth_url] is the base URL path to the cvmauth backend. /// `auth_url` is the base URL path to the cvmauth server to use.
/// [secret_key] is the given secret key. /// `secret_key` is the given secret key for said server.
/// ///
/// # Example /// # Example
/// ```rust /// ```rust
@ -37,7 +37,7 @@ impl Client {
&self, &self,
token: String, token: String,
ip: String, ip: String,
) -> result::Result<types::AuthResponse> { ) -> result::Result<types::AuthJoinResponse> {
let (tx, rx) = oneshot::channel(); let (tx, rx) = oneshot::channel();
let _ = self let _ = self
@ -50,7 +50,6 @@ impl Client {
.await; .await;
match rx.await { match rx.await {
// TODO: Convert JSON failures to an error.
Ok(res) => Ok(res), Ok(res) => Ok(res),
// See above FIXME // See above FIXME
Err(_err) => Err(result::Error::GeneralFail), Err(_err) => Err(result::Error::GeneralFail),

View file

@ -2,7 +2,7 @@ use crate::user_types::Rank;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug)] #[derive(Serialize, Deserialize, Debug)]
pub struct AuthRequest { pub struct AuthJoinBody {
#[serde(rename = "secretKey")] #[serde(rename = "secretKey")]
pub secret_key: String, pub secret_key: String,
@ -13,11 +13,15 @@ pub struct AuthRequest {
} }
#[derive(Deserialize, Debug)] #[derive(Deserialize, Debug)]
pub struct AuthResponse { pub struct AuthJoinResponse {
pub success: bool, pub success: bool,
#[serde(rename = "clientSuccess")] #[serde(rename = "clientSuccess")]
pub client_sucess: bool, pub client_sucess: bool,
pub username: Option<String>, pub username: Option<String>,
pub error: Option<String>, pub error: Option<String>,
pub rank: Rank, pub rank: Rank,
pub banned: Option<bool>,
#[serde(rename = "banReason")]
pub ban_reason: Option<String>
} }