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