auth: add ban stuff to AuthJoinResponse
renames them just to be nice.
This commit is contained in:
parent
37339e2580
commit
0bb73e1194
3 changed files with 13 additions and 10 deletions
|
@ -15,7 +15,7 @@ pub(crate) enum AuthActorMessage {
|
|||
ip: String,
|
||||
|
||||
// Oneshot response
|
||||
tx: oneshot::Sender<types::AuthResponse>,
|
||||
tx: oneshot::Sender<types::AuthJoinResponse>,
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -47,8 +47,8 @@ impl AuthActor {
|
|||
&mut self,
|
||||
session_token: String,
|
||||
ip: String,
|
||||
) -> result::Result<types::AuthResponse> {
|
||||
let request_json = types::AuthRequest {
|
||||
) -> result::Result<types::AuthJoinResponse> {
|
||||
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::<types::AuthResponse>().await?;
|
||||
let deserialized_response = raw_response.json::<types::AuthJoinResponse>().await?;
|
||||
|
||||
Ok(deserialized_response)
|
||||
}
|
||||
|
|
|
@ -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<types::AuthResponse> {
|
||||
) -> result::Result<types::AuthJoinResponse> {
|
||||
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),
|
||||
|
|
|
@ -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<String>,
|
||||
pub error: Option<String>,
|
||||
pub rank: Rank,
|
||||
|
||||
pub banned: Option<bool>,
|
||||
#[serde(rename = "banReason")]
|
||||
pub ban_reason: Option<String>
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue