diff --git a/src/server/session/has_joined.rs b/src/server/session/has_joined.rs index 268eb17..a4fee66 100644 --- a/src/server/session/has_joined.rs +++ b/src/server/session/has_joined.rs @@ -10,16 +10,17 @@ */ use anyhow::anyhow; +use log::info; use tide::{prelude::*, Request, Result}; use yggdrasil::Database; use yggdrasil::errors::YggdrasilError; +use yggdrasil::structs::game_profile::GameProfile; use yggdrasil::structs::profile::Profile; use yggdrasil::structs::session::Session; -use yggdrasil::structs::game_profile::GameProfile; #[derive(Deserialize, Debug)] -struct HasJoinedBody { +struct HasJoinedQuery { pub username: String, #[serde(rename = "serverId")] @@ -29,13 +30,13 @@ struct HasJoinedBody { } pub async fn has_joined(mut req: Request) -> Result { - let Ok(body) = req.body_json::().await else { + let Ok(query) = req.query::() else { // No args return Err(YggdrasilError::new_bad_request("One or more required fields was missing.").into()) }; // Get profile - let Some(profile) = Profile::from_name(req.state(), body.username).await else { + let Some(profile) = Profile::from_name(req.state(), query.username.to_string()).await else { return Err(YggdrasilError::new_bad_request("Profile does not exist.").into()) }; @@ -45,12 +46,18 @@ pub async fn has_joined(mut req: Request) -> Result { }; // Check IP if requested - if let Some(ip) = body.ip { + if let Some(ip) = query.ip { if ip != session.ip_addr { return Err(YggdrasilError::new_forbidden("IP address does not match.").into()) } } + // TODO: what is server id and why doesn't it match? + // Check server id + // if query.server_id != session.server_id { + // return Err(YggdrasilError::new_forbidden("Server ID does not match.").into()) + // } + // Remove session session.delete(req.state()).await?;