From 5d53ceb09cc0c3c420c72ee5949bcd0171e8c2d2 Mon Sep 17 00:00:00 2001 From: trisua Date: Sun, 13 Apr 2025 01:37:39 -0400 Subject: [PATCH] fix: allow MANAGE_COMMUNITIES user permission to bypass read access --- crates/app/src/routes/pages/communities.rs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/crates/app/src/routes/pages/communities.rs b/crates/app/src/routes/pages/communities.rs index 2405c45..d5679c6 100644 --- a/crates/app/src/routes/pages/communities.rs +++ b/crates/app/src/routes/pages/communities.rs @@ -19,8 +19,16 @@ macro_rules! check_permissions { ($community:ident, $jar:ident, $data:ident, $user:ident) => {{ let mut is_member: bool = false; let mut can_manage_pins: bool = false; + let mut can_manage_communities: bool = false; if let Some(ref ua) = $user { + if ua + .permissions + .check(tetratto_core::model::permissions::FinePermission::MANAGE_COMMUNITIES) + { + can_manage_communities = true; + } + if let Ok(membership) = $data .0 .get_membership_by_owner_community(ua.id, $community.id) @@ -44,10 +52,14 @@ macro_rules! check_permissions { match $community.read_access { CommunityReadAccess::Joined => { - if !is_member { - (false, can_manage_pins) + if !can_manage_communities { + if !is_member { + (false, can_manage_pins) + } else { + (true, can_manage_pins) + } } else { - (true, can_manage_pins) + (true, true) } } _ => (true, can_manage_pins),