mirror of
https://github.com/LibreQoE/LibreQoS.git
synced 2025-02-25 18:55:32 -06:00
feat: add /getUsers endpoint to retrieve web users
This commit is contained in:
committed by
Herbert Wolverson (aider)
parent
34804c03e8
commit
512a1940fa
@@ -46,6 +46,7 @@ pub fn local_api() -> Router {
|
||||
.route("/allShapedDevices", get(config::all_shaped_devices))
|
||||
.route("/updateConfig", post(config::update_lqosd_config))
|
||||
.route("/updateNetworkAndDevices", post(config::update_network_and_devices))
|
||||
.route("/getUsers", get(config::get_users))
|
||||
.route("/circuitById", post(circuit::get_circuit_by_id))
|
||||
.route("/requestAnalysis/:ip", get(packet_analysis::request_analysis))
|
||||
.route("/pcapDump/:id", get(packet_analysis::pcap_dump))
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::sync::Arc;
|
||||
use axum::{Extension, Json};
|
||||
use axum::http::StatusCode;
|
||||
use lqos_config::{Config, ConfigShapedDevices, ShapedDevice};
|
||||
use lqos_config::{Config, ConfigShapedDevices, ShapedDevice, WebUser};
|
||||
use crate::node_manager::auth::LoginResult;
|
||||
use default_net::get_interfaces;
|
||||
use serde::Deserialize;
|
||||
@@ -117,4 +117,15 @@ pub async fn update_network_and_devices(
|
||||
SHAPED_DEVICES.store(Arc::new(copied));
|
||||
|
||||
"Ok".to_string()
|
||||
}
|
||||
|
||||
pub async fn get_users(
|
||||
Extension(login): Extension<LoginResult>,
|
||||
) -> Result<Json<Vec<WebUser>>, StatusCode> {
|
||||
if login != LoginResult::Admin {
|
||||
return Err(StatusCode::FORBIDDEN);
|
||||
}
|
||||
let users = lqos_config::WebUsers::load_or_create()
|
||||
.map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?;
|
||||
Ok(Json(users.get_users()))
|
||||
}
|
||||
Reference in New Issue
Block a user