Working auth
This commit is contained in:
@@ -12,10 +12,13 @@ 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!(
|
||||||
.call()
|
"https://vxchat.netlify.app/api/auth?token={token}&key={}",
|
||||||
.context("Failed to authenticate")?;
|
server.config.server_key
|
||||||
|
))
|
||||||
|
.call()
|
||||||
|
.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()?)?;
|
||||||
client.set_uuid(&api_res.user_id);
|
client.set_uuid(&api_res.user_id);
|
||||||
LOGGER.info(format!("{} successfully authenticated", api_res.user_id));
|
LOGGER.info(format!("{} successfully authenticated", api_res.user_id));
|
||||||
|
|||||||
+5
-3
@@ -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!(""),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user