1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2024-11-25 23:09:22 +00:00

Fix bad route

This commit is contained in:
Pierre HUBERT 2021-05-14 18:45:48 +02:00
parent 4365caf602
commit e619d71601
3 changed files with 17 additions and 16 deletions

View File

@ -7,7 +7,6 @@ use crate::api_data::admin::admin_auth_options::AdminAuthOptions;
use crate::api_data::admin::admin_auth_success::AdminAuthSuccess; use crate::api_data::admin::admin_auth_success::AdminAuthSuccess;
use crate::api_data::admin::admin_id_api::AdminIDAPI; use crate::api_data::admin::admin_id_api::AdminIDAPI;
use crate::api_data::admin::admin_info_api::AdminInfoAPI; use crate::api_data::admin::admin_info_api::AdminInfoAPI;
use crate::api_data::admin::admin_keys_api::AdminKeyAPI;
use crate::api_data::admin::admin_res_create_reset_token::AdminResCreateResetToken; use crate::api_data::admin::admin_res_create_reset_token::AdminResCreateResetToken;
use crate::data::admin::NewAdminGeneralSettings; use crate::data::admin::NewAdminGeneralSettings;
use crate::data::base_request_handler::BaseRequestHandler; use crate::data::base_request_handler::BaseRequestHandler;
@ -69,20 +68,6 @@ pub fn get_admin_info(r: &mut HttpRequestHandler) -> RequestResult {
r.set_response(AdminInfoAPI::new(&admin)) r.set_response(AdminInfoAPI::new(&admin))
} }
/// Get an admin keys
pub fn get_keys_list(r: &mut HttpRequestHandler) -> RequestResult {
let admin_id = r.post_admin_id("id")?;
if admin_id != r.admin_id()? {
// TODO : implement
unimplemented!();
}
let keys = admin_account_key_helper::get_admin_keys(admin_id)?;
r.set_response(keys.iter().map(AdminKeyAPI::new).collect::<Vec<AdminKeyAPI>>())
}
/// Update general settings /// Update general settings
pub fn update_general_settings(r: &mut HttpRequestHandler) -> RequestResult { pub fn update_general_settings(r: &mut HttpRequestHandler) -> RequestResult {
let admin_id = r.post_admin_id("id")?; let admin_id = r.post_admin_id("id")?;

View File

@ -11,6 +11,7 @@ use crate::data::http_request_handler::HttpRequestHandler;
use crate::data::webauthn_config::get_wan; use crate::data::webauthn_config::get_wan;
use crate::helpers::{admin_access_token_helper, admin_account_helper, admin_account_key_helper, admin_key_authentication_challenges_helper, admin_key_registration_challenges_helper}; use crate::helpers::{admin_access_token_helper, admin_account_helper, admin_account_key_helper, admin_key_authentication_challenges_helper, admin_key_registration_challenges_helper};
use crate::routes::RequestResult; use crate::routes::RequestResult;
use crate::api_data::admin::admin_keys_api::AdminKeyAPI;
impl HttpRequestHandler { impl HttpRequestHandler {
pub fn post_admin_auth_key(&mut self, name_mail: &str, name_key_id: &str) -> Res<AdminKey> { pub fn post_admin_auth_key(&mut self, name_mail: &str, name_key_id: &str) -> Res<AdminKey> {
@ -31,6 +32,21 @@ impl HttpRequestHandler {
} }
} }
/// Get an admin keys
pub fn get_keys_list(r: &mut HttpRequestHandler) -> RequestResult {
let admin_id = r.post_admin_id("id")?;
if admin_id != r.admin_id()? {
// TODO : implement
unimplemented!();
}
let keys = admin_account_key_helper::get_admin_keys(admin_id)?;
r.set_response(keys.iter().map(AdminKeyAPI::new).collect::<Vec<AdminKeyAPI>>())
}
/// Generate a challenge to register a new key /// Generate a challenge to register a new key
pub fn challenge_register_key(r: &mut HttpRequestHandler) -> RequestResult { pub fn challenge_register_key(r: &mut HttpRequestHandler) -> RequestResult {
let mut wan = get_wan(); let mut wan = get_wan();

View File

@ -352,11 +352,11 @@ pub fn get_routes() -> Vec<Route> {
Route::admin_post("/admin/accounts/sign_out", Box::new(admin_account_controller::sign_out)), Route::admin_post("/admin/accounts/sign_out", Box::new(admin_account_controller::sign_out)),
Route::admin_post("/admin/accounts/id", Box::new(admin_account_controller::get_admin_id)), Route::admin_post("/admin/accounts/id", Box::new(admin_account_controller::get_admin_id)),
Route::admin_post("/admin/accounts/info", Box::new(admin_account_controller::get_admin_info)), Route::admin_post("/admin/accounts/info", Box::new(admin_account_controller::get_admin_info)),
Route::admin_post("/admin/accounts/keys", Box::new(admin_account_controller::get_keys_list)),
Route::admin_post("/admin/accounts/update_general_settings", Box::new(admin_account_controller::update_general_settings)), Route::admin_post("/admin/accounts/update_general_settings", Box::new(admin_account_controller::update_general_settings)),
Route::admin_post("/admin/accounts/generate_reset_token", Box::new(admin_account_controller::generate_reset_token)), Route::admin_post("/admin/accounts/generate_reset_token", Box::new(admin_account_controller::generate_reset_token)),
// Admin security keys controller // Admin security keys controller
Route::admin_post("/admin/keys/list", Box::new(admin_keys_controller::get_keys_list)),
Route::admin_post("/admin/keys/challenge_register_key", Box::new(admin_keys_controller::challenge_register_key)), Route::admin_post("/admin/keys/challenge_register_key", Box::new(admin_keys_controller::challenge_register_key)),
Route::admin_post("/admin/keys/register_key", Box::new(admin_keys_controller::register_key)), Route::admin_post("/admin/keys/register_key", Box::new(admin_keys_controller::register_key)),
Route::admin_post("/admin/keys/delete_auth_key", Box::new(admin_keys_controller::delete_auth_key)), Route::admin_post("/admin/keys/delete_auth_key", Box::new(admin_keys_controller::delete_auth_key)),