diff --git a/src/server.rs b/src/server.rs index a442026..ab92f62 100644 --- a/src/server.rs +++ b/src/server.rs @@ -26,7 +26,7 @@ use crate::{ cli, logger, plugin::{Plugin, loader::PluginLoader, types::LoaderMessage}, types, - utils::{self, client::Client}, + utils::{self, auth, client::Client}, }; #[derive(serde::Serialize, serde::Deserialize)] @@ -107,6 +107,9 @@ impl Server { // Initialize plugins Self::LOGGER.info("Initializing plugins"); + Self::LOGGER.info("Authenticating"); + auth::test(self)?; + // Initialize CLI Self::LOGGER.info("Initializing CLI"); cli::start_cli(self.clone(), plugin_loader); diff --git a/src/utils/auth.rs b/src/utils/auth.rs index 810e4db..77f89e2 100644 --- a/src/utils/auth.rs +++ b/src/utils/auth.rs @@ -26,3 +26,14 @@ pub fn auth(server: &Arc, client: &mut Client, token: &str) -> crate::Re LOGGER.info(format!("{} successfully authenticated", api_res.user_id)); Ok(api_res.user_id) } + +pub fn test(server: &Arc) -> crate::Result<()> { + ureq::get(format!( + "https://vxchat.netlify.app/api/test-auth?key={}&id={}", + server.config.server_key, server.config.server_id + )) + .call() + .context("Failed to authenticate")?; + + Ok(()) +}