mirror of
https://git.verdigado.com/NB-Public/simple-wkd.git
synced 2024-10-30 05:05:52 +01:00
Improve logging
This commit is contained in:
parent
8484febb9d
commit
82a7e4539b
2 changed files with 7 additions and 3 deletions
|
@ -5,7 +5,6 @@ mod settings;
|
||||||
mod utils;
|
mod utils;
|
||||||
|
|
||||||
use crate::settings::SETTINGS;
|
use crate::settings::SETTINGS;
|
||||||
use crate::utils::key_exists;
|
|
||||||
|
|
||||||
use self::confirmation::{confirm_action, send_confirmation_email};
|
use self::confirmation::{confirm_action, send_confirmation_email};
|
||||||
use self::management::{clean_stale, store_pending_addition, store_pending_deletion, Action};
|
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!("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))
|
HttpServer::new(|| App::new().service(submit).service(confirm).service(delete))
|
||||||
.bind(("127.0.0.1", SETTINGS.port))?
|
.bind(("127.0.0.1", SETTINGS.port))?
|
||||||
.run()
|
.run()
|
||||||
|
@ -81,7 +81,6 @@ async fn confirm(token: web::Path<Token>) -> Result<String> {
|
||||||
|
|
||||||
#[get("/api/delete/{address}")]
|
#[get("/api/delete/{address}")]
|
||||||
async fn delete(email: web::Path<Email>) -> Result<String> {
|
async fn delete(email: web::Path<Email>) -> Result<String> {
|
||||||
key_exists(&email.address)?;
|
|
||||||
let token = gen_random_token();
|
let token = gen_random_token();
|
||||||
store_pending_deletion(email.address.clone(), &token)?;
|
store_pending_deletion(email.address.clone(), &token)?;
|
||||||
send_confirmation_email(&email.address, &Action::Delete, &token)?;
|
send_confirmation_email(&email.address, &Action::Delete, &token)?;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::pending_path;
|
use crate::pending_path;
|
||||||
use crate::settings::SETTINGS;
|
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::PENDING_FOLDER;
|
||||||
use crate::{errors::Error, utils::get_filename};
|
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> {
|
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());
|
let pending = Pending::build_delete(email.clone());
|
||||||
store_pending(&pending, token)?;
|
store_pending(&pending, token)?;
|
||||||
debug!(
|
debug!(
|
||||||
|
|
Loading…
Reference in a new issue