From e985bae46902297091a9548381bd9110ec5a02c2 Mon Sep 17 00:00:00 2001 From: Ryan Date: Tue, 4 Oct 2022 23:35:34 -0700 Subject: [PATCH] Use StatusCode in auth server response check --- src/server.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/server.rs b/src/server.rs index acbb2e7..7139db3 100644 --- a/src/server.rs +++ b/src/server.rs @@ -13,7 +13,7 @@ use flume::{Receiver, Sender}; use num::BigInt; use rand::rngs::OsRng; use rayon::iter::ParallelIterator; -use reqwest::Client as HttpClient; +use reqwest::{Client as HttpClient, StatusCode}; use rsa::{PaddingScheme, PublicKeyParts, RsaPrivateKey}; use serde::Deserialize; use serde_json::{json, Value}; @@ -715,17 +715,18 @@ async fn handle_login( &hex_hash, &remote_addr.ip(), ); + let resp = server.0.http_client.get(url).send().await?; - match resp.status().as_u16() { - 200 => (), - 204 => { + match resp.status() { + StatusCode::OK => {} + StatusCode::NO_CONTENT => { let reason = Text::translate("multiplayer.disconnect.unverified_username"); c.enc.write_packet(&DisconnectLogin { reason }).await?; bail!("Could not verify username"); } status => { - bail!("session server GET request failed: {status}"); + bail!("session server GET request failed (status code {status})"); } }