mirror of
https://github.com/italicsjenga/valence.git
synced 2024-12-24 06:51:30 +11:00
Use StatusCode in auth server response check
This commit is contained in:
parent
b330f97642
commit
e985bae469
|
@ -13,7 +13,7 @@ use flume::{Receiver, Sender};
|
||||||
use num::BigInt;
|
use num::BigInt;
|
||||||
use rand::rngs::OsRng;
|
use rand::rngs::OsRng;
|
||||||
use rayon::iter::ParallelIterator;
|
use rayon::iter::ParallelIterator;
|
||||||
use reqwest::Client as HttpClient;
|
use reqwest::{Client as HttpClient, StatusCode};
|
||||||
use rsa::{PaddingScheme, PublicKeyParts, RsaPrivateKey};
|
use rsa::{PaddingScheme, PublicKeyParts, RsaPrivateKey};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use serde_json::{json, Value};
|
use serde_json::{json, Value};
|
||||||
|
@ -715,17 +715,18 @@ async fn handle_login<C: Config>(
|
||||||
&hex_hash,
|
&hex_hash,
|
||||||
&remote_addr.ip(),
|
&remote_addr.ip(),
|
||||||
);
|
);
|
||||||
|
|
||||||
let resp = server.0.http_client.get(url).send().await?;
|
let resp = server.0.http_client.get(url).send().await?;
|
||||||
|
|
||||||
match resp.status().as_u16() {
|
match resp.status() {
|
||||||
200 => (),
|
StatusCode::OK => {}
|
||||||
204 => {
|
StatusCode::NO_CONTENT => {
|
||||||
let reason = Text::translate("multiplayer.disconnect.unverified_username");
|
let reason = Text::translate("multiplayer.disconnect.unverified_username");
|
||||||
c.enc.write_packet(&DisconnectLogin { reason }).await?;
|
c.enc.write_packet(&DisconnectLogin { reason }).await?;
|
||||||
bail!("Could not verify username");
|
bail!("Could not verify username");
|
||||||
}
|
}
|
||||||
status => {
|
status => {
|
||||||
bail!("session server GET request failed: {status}");
|
bail!("session server GET request failed (status code {status})");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue