diff --git a/backend/src/handlers/me.rs b/backend/src/handlers/me.rs index 76c4757..df717c8 100644 --- a/backend/src/handlers/me.rs +++ b/backend/src/handlers/me.rs @@ -14,7 +14,7 @@ use serde::Serialize; use crate::auth::middleware::AuthUser; use crate::error::AppError; use crate::handlers::upload::compute_storage_quota; -use crate::models::user::User; +use crate::models::user::{User, UserRole}; use crate::services::config; use crate::state::AppState; @@ -37,12 +37,26 @@ pub async fn get_quota( let estimate = compute_storage_quota(&state).await; + // Raw server telemetry (free disk, concurrent uploader count) is staff-only — it + // must never reach a guest, even though the guest upload UI no longer renders it. + // A guest still gets their own `used`/`limit` so enforcement stays transparent to + // the code paths that consume it; only the server-wide fields are zeroed. + let is_staff = matches!(auth.role, UserRole::Host | UserRole::Admin); + Ok(Json(QuotaDto { enabled: estimate.limit_bytes.is_some(), used_bytes: user.total_upload_bytes, limit_bytes: estimate.limit_bytes, - active_uploaders: estimate.active_uploaders, - free_disk_bytes: estimate.free_disk_bytes, + active_uploaders: if is_staff { + estimate.active_uploaders + } else { + 0 + }, + free_disk_bytes: if is_staff { + estimate.free_disk_bytes + } else { + 0 + }, })) } diff --git a/frontend/src/routes/account/+page.svelte b/frontend/src/routes/account/+page.svelte index eceb89e..739cef7 100644 --- a/frontend/src/routes/account/+page.svelte +++ b/frontend/src/routes/account/+page.svelte @@ -431,8 +431,9 @@ - - {#if $quotaStore.enabled && $quotaStore.limit_bytes != null} + + {#if (role === 'host' || role === 'admin') && $quotaStore.enabled && $quotaStore.limit_bytes != null}