From 38700ee4cb5d5743251b5d4e3a223cebd4a987b8 Mon Sep 17 00:00:00 2001 From: selfhoster1312 Date: Sat, 19 Sep 2026 10:38:32 +0200 Subject: [PATCH] fix: Domain admin can see domain in home --- src/db/common.rs | 2 +- src/db/user.rs | 6 ++++++ templates/home.html | 16 ++++++++-------- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/db/common.rs b/src/db/common.rs index d75ba10..f7408c6 100644 --- a/src/db/common.rs +++ b/src/db/common.rs @@ -42,7 +42,7 @@ impl Database { .list_all_domains() .await? .into_iter() - .filter(|d| user.role.can_see_domain(&d.name)) + .filter(|d| user.can_see_domain(&d.name)) .collect()) } } diff --git a/src/db/user.rs b/src/db/user.rs index 967426a..b7c8bcd 100644 --- a/src/db/user.rs +++ b/src/db/user.rs @@ -84,6 +84,12 @@ impl User { pub fn can_create_domain(&self) -> bool { self.role.can_perform(&Operation::CreateDomain) } + + pub fn can_see_domain(&self, domain: &str) -> bool { + let allowed = self.role.can_see_domain(domain); + tracing::debug!("{} can see domain {}: {}", self.mail, domain, allowed); + allowed + } } impl fmt::Display for User { diff --git a/templates/home.html b/templates/home.html index 15eb0da..13f717e 100644 --- a/templates/home.html +++ b/templates/home.html @@ -14,15 +14,15 @@ -
-

Active domains you can see

- -
{% endif %} +
+

Active domains you can see

+ +
{% if other_users %}

Other users you have permission to see on your own domain