mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2025-07-10 01:22:48 +00:00
Start to log administrator actions
This commit is contained in:
20
src/helpers/admin_log_helper.rs
Normal file
20
src/helpers/admin_log_helper.rs
Normal file
@ -0,0 +1,20 @@
|
||||
//! # Admin logs management
|
||||
//!
|
||||
//! @author Pierre Hubert
|
||||
|
||||
use crate::constants::database_tables_names::ADMIN_LOGS_TABLE;
|
||||
use crate::data::admin::AdminID;
|
||||
use crate::data::admin_action_log::AdminAction;
|
||||
use crate::data::error::Res;
|
||||
use crate::helpers::database;
|
||||
use crate::utils::date_utils::time;
|
||||
|
||||
/// Record an administrator action
|
||||
pub fn log_admin_action(admin: AdminID, ip: &str, action: AdminAction) -> Res {
|
||||
database::InsertQuery::new(ADMIN_LOGS_TABLE)
|
||||
.add_admin_id("admin_id", admin)
|
||||
.add_str("ip", ip)
|
||||
.add_u64("time", time())
|
||||
.add_str("action", &serde_json::to_string(&action)?)
|
||||
.insert_drop_result()
|
||||
}
|
@ -27,4 +27,5 @@ pub mod admin_account_key_helper;
|
||||
pub mod admin_access_token_helper;
|
||||
pub mod admin_key_registration_challenges_helper;
|
||||
pub mod admin_key_authentication_challenges_helper;
|
||||
pub mod admin_roles_helper;
|
||||
pub mod admin_roles_helper;
|
||||
pub mod admin_log_helper;
|
Reference in New Issue
Block a user