0
0
Fork 0
mirror of https://git.verdigado.com/NB-Public/simple-wkd.git synced 2024-12-05 03:12:50 +01:00

Improve logging

This commit is contained in:
Delta1925 2023-04-14 19:30:38 +02:00
parent 8484febb9d
commit 82a7e4539b
No known key found for this signature in database
GPG key ID: 1C21ACE44193CB25
2 changed files with 7 additions and 3 deletions

View file

@ -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<Token>) -> Result<String> {
#[get("/api/delete/{address}")]
async fn delete(email: web::Path<Email>) -> Result<String> {
key_exists(&email.address)?;
let token = gen_random_token();
store_pending_deletion(email.address.clone(), &token)?;
send_confirmation_email(&email.address, &Action::Delete, &token)?;

View file

@ -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!(