added audit logs
This commit is contained in:
parent
322a90b62e
commit
0ec1c988bc
3 changed files with 34 additions and 13 deletions
|
@ -114,10 +114,10 @@ pub async fn change_settings(
|
|||
user::update_info(&mut *db, &user.id, new_username, new_email).await?;
|
||||
|
||||
info!(
|
||||
"[audit|{}] [{}] changed username/email (account ID {})",
|
||||
"[audit|{}] [{}] changed username/email (from {})",
|
||||
client_ip,
|
||||
user.username,
|
||||
user.id.to_string(),
|
||||
user.username,
|
||||
);
|
||||
|
||||
Ok(Redirect::to(uri!("/account", show_settings)).into())
|
||||
|
@ -189,7 +189,11 @@ pub async fn change_password(
|
|||
let new_password_hash = task::spawn_blocking(move || pw::hash(&new_password)).await??;
|
||||
user::update_password(&mut *db, &user.id, &new_password_hash).await?;
|
||||
|
||||
info!("[audit|{}] [{}] changed password", client_ip, user.username);
|
||||
info!(
|
||||
"[audit|{}] [{}] changed password",
|
||||
client_ip,
|
||||
user.id.to_string()
|
||||
);
|
||||
|
||||
Ok(Redirect::to(uri!("/account", show_settings)).into())
|
||||
}
|
||||
|
@ -211,7 +215,11 @@ pub async fn export_data(
|
|||
let tags = doll::list(&mut *db, &user.id).await?;
|
||||
let reserved_tags = doll::list_archived(&mut *db, &user.id).await?;
|
||||
|
||||
info!("[audit|{}] [{}] exported data", client_ip, user.username);
|
||||
info!(
|
||||
"[audit|{}] [{}] exported data",
|
||||
client_ip,
|
||||
user.id.to_string()
|
||||
);
|
||||
|
||||
Ok(Json(DataDump {
|
||||
account: user,
|
||||
|
@ -256,7 +264,9 @@ pub async fn confirm_delete(
|
|||
|
||||
info!(
|
||||
"[audit|{}] [{}] deleted tag {:0>6}",
|
||||
client_ip, user.username, id
|
||||
client_ip,
|
||||
user.id.to_string(),
|
||||
id
|
||||
);
|
||||
|
||||
Ok(Redirect::to(uri!("/account", index)).into())
|
||||
|
@ -280,7 +290,11 @@ pub async fn confirm_terminate_account(
|
|||
session::logout(cookies);
|
||||
trx.commit().await?;
|
||||
|
||||
info!("[audit|{}] [{}] deleted account", client_ip, user.username);
|
||||
info!(
|
||||
"[audit|{}] [{}] deleted account",
|
||||
client_ip,
|
||||
user.id.to_string()
|
||||
);
|
||||
|
||||
Ok(Redirect::to("/").into())
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ pub async fn handle_login(
|
|||
|
||||
let miss = (|username: String| {
|
||||
move || {
|
||||
info!("[audit|{}] [{}] login failure", client_ip, username);
|
||||
info!("[audit|{}] login failure ({})", client_ip, username);
|
||||
PageResponse::Page(Template::render(
|
||||
"account/login",
|
||||
context! {failure: true, meta},
|
||||
|
@ -75,7 +75,7 @@ pub async fn handle_login(
|
|||
}
|
||||
})(String::from(values.username));
|
||||
|
||||
info!("[audit|{}] [{}] login attempt", client_ip, &values.username);
|
||||
info!("[audit|{}] login attempt ({})", client_ip, &values.username);
|
||||
|
||||
let user_in_db = user::get(db, &values.username).await?;
|
||||
let user = match user_in_db {
|
||||
|
@ -90,8 +90,10 @@ pub async fn handle_login(
|
|||
if right_password && user.enabled {
|
||||
session::login(cookies, &user.id);
|
||||
info!(
|
||||
"[audit|{}] [{}] login successful",
|
||||
client_ip, &values.username
|
||||
"[audit|{}] [{}] login successful ({})",
|
||||
client_ip,
|
||||
user.id.to_string(),
|
||||
&values.username
|
||||
);
|
||||
let next_url = String::from(next.unwrap_or("/"));
|
||||
Ok(Redirect::to(next_url).into())
|
||||
|
@ -193,7 +195,8 @@ pub async fn handle_register(
|
|||
|
||||
info!(
|
||||
"[audit|{}] [{}] account creation",
|
||||
client_ip, &values.username
|
||||
client_ip,
|
||||
&account_id.to_string()
|
||||
);
|
||||
session::login(cookies, &account_id);
|
||||
|
||||
|
|
|
@ -238,14 +238,18 @@ pub async fn handle_register(
|
|||
if creation_status.is_err() {
|
||||
info!(
|
||||
"[audit|{}] [{}] failed to register tag {}",
|
||||
client_ip, user.username, tag.ident
|
||||
client_ip,
|
||||
user.id.to_string(),
|
||||
tag.ident
|
||||
);
|
||||
}
|
||||
creation_status?;
|
||||
|
||||
info!(
|
||||
"[audit|{}] [{}] registered tag {}",
|
||||
client_ip, user.username, tag.ident
|
||||
client_ip,
|
||||
user.id.to_string(),
|
||||
tag.ident
|
||||
);
|
||||
|
||||
Ok(Redirect::to(uri!(public::show_profile(Some(tag.ident), microchip_id))).into())
|
||||
|
|
Loading…
Add table
Reference in a new issue