Skip to content

Commit

Permalink
add network devices stats to overview endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
t-aleksander committed Dec 17, 2024
1 parent 020a7ef commit ffdfd6d
Show file tree
Hide file tree
Showing 6 changed files with 450 additions and 398 deletions.
3 changes: 3 additions & 0 deletions src/auth/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,9 @@ macro_rules! role {
state: &S,
) -> Result<Self, Self::Rejection> {
let session_info = SessionInfo::from_request_parts(parts, state).await?;
if !session_info.user.is_active {
return Err(WebError::Forbidden("user is disabled".into()));
}
let appstate = AppState::from_ref(state);
$(
let groups_with_permission = Group::find_by_permission(
Expand Down
4 changes: 2 additions & 2 deletions src/db/models/wireguard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ impl WireguardNetwork<Id> {
}

/// Retrieves stats for specified devices
async fn device_stats(
pub(crate) async fn device_stats(
&self,
conn: &PgPool,
devices: &[Device<Id>],
Expand Down Expand Up @@ -811,7 +811,7 @@ impl WireguardNetwork<Id> {
d.id, d.name, d.wireguard_pubkey, d.user_id, d.created, d.description, d.device_type \"device_type: DeviceType\" \
FROM device d \
JOIN s ON d.id = s.device_id \
WHERE s.latest_handshake >= $1 AND s.network = $2",
WHERE s.latest_handshake >= $1 AND s.network = $2 AND d.device_type = 'user'::device_type",
oldest_handshake,
self.id,
)
Expand Down
1 change: 1 addition & 0 deletions src/handlers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub(crate) mod auth;
pub(crate) mod forward_auth;
pub(crate) mod group;
pub(crate) mod mail;
pub(crate) mod network_devices;
#[cfg(feature = "openid")]
pub(crate) mod openid_clients;
#[cfg(feature = "openid")]
Expand Down
Loading

0 comments on commit ffdfd6d

Please sign in to comment.