1
0
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:
2021-07-10 19:40:41 +02:00
parent b20c261c7d
commit 5d97ca18cb
10 changed files with 86 additions and 11 deletions

View 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<_>>())
}

View File

@ -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;