diff --git a/src/main.rs b/src/main.rs index 5073882..f72df86 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,7 +5,6 @@ mod settings; mod utils; use crate::settings::SETTINGS; -use crate::utils::key_exists; use self::confirmation::{confirm_action, send_confirmation_email}; use self::management::{clean_stale, store_pending_addition, store_pending_deletion, Action}; @@ -52,6 +51,7 @@ async fn main() -> std::io::Result<()> { info!("Cleanup completed!"); } }); + info!("Running server on http://127.0.0.1:{} (External URL: {})", SETTINGS.port, SETTINGS.external_url); HttpServer::new(|| App::new().service(submit).service(confirm).service(delete)) .bind(("127.0.0.1", SETTINGS.port))? .run() @@ -81,7 +81,6 @@ async fn confirm(token: web::Path) -> Result { #[get("/api/delete/{address}")] async fn delete(email: web::Path) -> Result { - key_exists(&email.address)?; let token = gen_random_token(); store_pending_deletion(email.address.clone(), &token)?; send_confirmation_email(&email.address, &Action::Delete, &token)?; diff --git a/src/management.rs b/src/management.rs index d809418..d44ba78 100644 --- a/src/management.rs +++ b/src/management.rs @@ -1,6 +1,6 @@ use crate::pending_path; use crate::settings::SETTINGS; -use crate::utils::get_user_file_path; +use crate::utils::{get_user_file_path, key_exists}; use crate::PENDING_FOLDER; use crate::{errors::Error, utils::get_filename}; @@ -74,6 +74,11 @@ pub fn store_pending_addition(pem: String, email: &str, token: &str) -> Result<( } pub fn store_pending_deletion(email: String, token: &str) -> Result<(), Error> { + match key_exists(&email) { + Err(Error::PathGeneration) => debug!("Error while generating path for user {}", email), + Err(Error::MissingKey) => debug!("There is no key for user {}", email), + _ => (), + } let pending = Pending::build_delete(email.clone()); store_pending(&pending, token)?; debug!(