mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2025-07-06 15:52:48 +00:00
Can access admin logs from the API
This commit is contained in:
20
src/controllers/admin/admin_logs_controller.rs
Normal file
20
src/controllers/admin/admin_logs_controller.rs
Normal file
@ -0,0 +1,20 @@
|
||||
//! # Admin action history (logs) controller
|
||||
//!
|
||||
//! @author Pierre Hubert
|
||||
|
||||
use crate::routes::RequestResult;
|
||||
use crate::data::http_request_handler::HttpRequestHandler;
|
||||
use crate::data::base_request_handler::BaseRequestHandler;
|
||||
use crate::helpers::{admin_roles_helper, admin_log_helper};
|
||||
use crate::constants::admin::AdminRole;
|
||||
use crate::api_data::admin::admin_log_api::AdminLogAPI;
|
||||
|
||||
/// Get the list of logs of the user
|
||||
pub fn get_list(r: &mut HttpRequestHandler) -> RequestResult {
|
||||
let logs = match admin_roles_helper::has_role(r.admin_id()?, AdminRole::ACCESS_ALL_ADMINS_LOGS)? {
|
||||
true => admin_log_helper::get_all_admin_logs(),
|
||||
false => admin_log_helper::get_admin_logs(r.admin_id()?)
|
||||
}?;
|
||||
|
||||
r.set_response(logs.iter().map(AdminLogAPI::new).collect::<Vec<_>>())
|
||||
}
|
@ -4,4 +4,5 @@
|
||||
|
||||
pub mod admin_account_controller;
|
||||
pub mod admin_keys_controller;
|
||||
pub mod admin_roles_controller;
|
||||
pub mod admin_roles_controller;
|
||||
pub mod admin_logs_controller;
|
Reference in New Issue
Block a user