Auth testing
This commit is contained in:
+4
-1
@@ -26,7 +26,7 @@ use crate::{
|
|||||||
cli, logger,
|
cli, logger,
|
||||||
plugin::{Plugin, loader::PluginLoader, types::LoaderMessage},
|
plugin::{Plugin, loader::PluginLoader, types::LoaderMessage},
|
||||||
types,
|
types,
|
||||||
utils::{self, client::Client},
|
utils::{self, auth, client::Client},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(serde::Serialize, serde::Deserialize)]
|
#[derive(serde::Serialize, serde::Deserialize)]
|
||||||
@@ -107,6 +107,9 @@ impl Server {
|
|||||||
// Initialize plugins
|
// Initialize plugins
|
||||||
Self::LOGGER.info("Initializing plugins");
|
Self::LOGGER.info("Initializing plugins");
|
||||||
|
|
||||||
|
Self::LOGGER.info("Authenticating");
|
||||||
|
auth::test(self)?;
|
||||||
|
|
||||||
// Initialize CLI
|
// Initialize CLI
|
||||||
Self::LOGGER.info("Initializing CLI");
|
Self::LOGGER.info("Initializing CLI");
|
||||||
cli::start_cli(self.clone(), plugin_loader);
|
cli::start_cli(self.clone(), plugin_loader);
|
||||||
|
|||||||
@@ -26,3 +26,14 @@ pub fn auth(server: &Arc<Server>, client: &mut Client, token: &str) -> crate::Re
|
|||||||
LOGGER.info(format!("{} successfully authenticated", api_res.user_id));
|
LOGGER.info(format!("{} successfully authenticated", api_res.user_id));
|
||||||
Ok(api_res.user_id)
|
Ok(api_res.user_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn test(server: &Arc<Server>) -> 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(())
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user