Working auth

This commit is contained in:
2025-10-14 00:07:23 +02:00
parent e425461a29
commit 2d0acdf67b
2 changed files with 12 additions and 7 deletions
+5 -2
View File
@@ -12,8 +12,11 @@ struct AuthApiRes {
user_id: String, user_id: String,
} }
pub fn auth(_server: &Arc<Server>, client: &mut Client, token: &str) -> crate::Result<String> { pub fn auth(server: &Arc<Server>, client: &mut Client, token: &str) -> crate::Result<String> {
let mut res = ureq::get(format!("https://vxchat.netlify.app/api/auth?token={token}")) let mut res = ureq::get(format!(
"https://vxchat.netlify.app/api/auth?token={token}&key={}",
server.config.server_key
))
.call() .call()
.context("Failed to authenticate")?; .context("Failed to authenticate")?;
let api_res: AuthApiRes = serde_json::from_str(&res.body_mut().read_to_string()?)?; let api_res: AuthApiRes = serde_json::from_str(&res.body_mut().read_to_string()?)?;
+5 -3
View File
@@ -12,9 +12,10 @@ use crate::{
#[derive(serde::Serialize, serde::Deserialize)] #[derive(serde::Serialize, serde::Deserialize)]
pub struct ServerConfig { pub struct ServerConfig {
server_name: String, pub server_name: String,
server_id: String, pub server_id: String,
port: u16, pub server_key: String,
pub port: u16,
} }
#[allow(dead_code)] #[allow(dead_code)]
@@ -31,6 +32,7 @@ impl Default for ServerConfig {
port: 7090, port: 7090,
server_name: format!("Server Name"), server_name: format!("Server Name"),
server_id: format!("offline-server"), server_id: format!("offline-server"),
server_key: format!(""),
} }
} }
} }