mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2024-11-26 07:19:22 +00:00
Can get the list of administrators from the api
This commit is contained in:
parent
d933dadf62
commit
cbf8d9b100
@ -55,6 +55,16 @@ pub fn get_admin_id(r: &mut HttpRequestHandler) -> RequestResult {
|
|||||||
r.set_response(AdminIDAPI::new(r.admin_id()?))
|
r.set_response(AdminIDAPI::new(r.admin_id()?))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get and return the list of administrators
|
||||||
|
pub fn get_list(r: &mut HttpRequestHandler) -> RequestResult {
|
||||||
|
let list = admin_account_helper::get_list()?
|
||||||
|
.iter()
|
||||||
|
.map(AdminInfoAPI::new)
|
||||||
|
.collect::<Vec<AdminInfoAPI>>();
|
||||||
|
|
||||||
|
r.set_response(list)
|
||||||
|
}
|
||||||
|
|
||||||
/// Get current admin information
|
/// Get current admin information
|
||||||
pub fn get_admin_info(r: &mut HttpRequestHandler) -> RequestResult {
|
pub fn get_admin_info(r: &mut HttpRequestHandler) -> RequestResult {
|
||||||
let admin = match r.has_post_parameter("id") {
|
let admin = match r.has_post_parameter("id") {
|
||||||
|
@ -32,6 +32,12 @@ pub fn exists(id: AdminID) -> Res<bool> {
|
|||||||
.map(|r| r > 0)
|
.map(|r| r > 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get the entire list of administrators
|
||||||
|
pub fn get_list() -> Res<Vec<Admin>> {
|
||||||
|
database::QueryInfo::new(ADMIN_LIST_TABLE)
|
||||||
|
.exec(db_to_admin)
|
||||||
|
}
|
||||||
|
|
||||||
/// Get admin information by ID
|
/// Get admin information by ID
|
||||||
pub fn find_admin_by_id(id: AdminID) -> Res<Admin> {
|
pub fn find_admin_by_id(id: AdminID) -> Res<Admin> {
|
||||||
database::QueryInfo::new(ADMIN_LIST_TABLE)
|
database::QueryInfo::new(ADMIN_LIST_TABLE)
|
||||||
|
@ -351,6 +351,7 @@ pub fn get_routes() -> Vec<Route> {
|
|||||||
Route::limited_admin_post_without_login("/admin/accounts/auth_with_reset_token", Box::new(admin_account_controller::auth_with_reset_token), LimitPolicy::FAILURE(5)),
|
Route::limited_admin_post_without_login("/admin/accounts/auth_with_reset_token", Box::new(admin_account_controller::auth_with_reset_token), LimitPolicy::FAILURE(5)),
|
||||||
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/list", Box::new(admin_account_controller::get_list)),
|
||||||
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/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)),
|
||||||
|
Loading…
Reference in New Issue
Block a user