Skip to content

Commit

Permalink
Simplify group membership check
Browse files Browse the repository at this point in the history
Co-authored-by: Stefan Melmuk <[email protected]>
  • Loading branch information
matlink and stefan0xC authored Jan 4, 2024
1 parent 073b4b9 commit cfa89d3
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/api/core/organizations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,10 +363,12 @@ async fn get_org_collections_details(org_id: &str, headers: ManagerHeadersLoose,
})
.collect();

// if current user is in any collection-assigned group
// or in a group having access to all collections
// or itself has access to all collections
assigned = assigned || has_collection_access_via_group.contains(&user_org.uuid);
// if the current user is not assigned and groups are enabled,
// check if they have access to the given collection via a group
if !assigned && CONFIG.org_groups_enabled()
{
assigned = GroupUser::get_group_members_for_collection(&col.uuid, &mut conn).await.contains(&user_org.uuid);
}

let mut json_object = col.to_json();
json_object["Assigned"] = json!(assigned);
Expand Down

0 comments on commit cfa89d3

Please sign in to comment.