mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2025-06-20 16:35:17 +00:00
Can update admin general settings
This commit is contained in:
@ -6,6 +6,7 @@ use crate::api_data::admin::admin_auth_options::AdminAuthOptions;
|
||||
use crate::api_data::admin::admin_auth_success::AdminAuthSuccess;
|
||||
use crate::api_data::admin::admin_id_api::AdminIDAPI;
|
||||
use crate::api_data::admin::admin_info_api::AdminInfoAPI;
|
||||
use crate::data::admin::NewAdminGeneralSettings;
|
||||
use crate::data::base_request_handler::BaseRequestHandler;
|
||||
use crate::data::http_request_handler::HttpRequestHandler;
|
||||
use crate::helpers::{admin_access_token_helper, admin_account_helper};
|
||||
@ -61,10 +62,31 @@ pub fn get_admin_info(r: &mut HttpRequestHandler) -> RequestResult {
|
||||
if admin_id == r.admin_id()? {
|
||||
admin_account_helper::find_admin_by_id(admin_id)?
|
||||
} else {
|
||||
// TODO
|
||||
unimplemented!();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
r.set_response(AdminInfoAPI::new(&admin))
|
||||
}
|
||||
|
||||
/// Update general settings
|
||||
pub fn update_general_settings(r: &mut HttpRequestHandler) -> RequestResult {
|
||||
let admin_id = r.post_admin_id("id")?;
|
||||
let new_name = r.post_string("name")?;
|
||||
let new_email = r.post_email("email")?;
|
||||
|
||||
if admin_id != r.admin_id()? {
|
||||
// TODO
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
admin_account_helper::set_general_settings(NewAdminGeneralSettings {
|
||||
id: admin_id,
|
||||
name: new_name,
|
||||
email: new_email,
|
||||
})?;
|
||||
|
||||
r.ok()
|
||||
}
|
Reference in New Issue
Block a user