1
0
Fork 0
mirror of https://github.com/dani-garcia/vaultwarden.git synced 2025-07-27 06:14:29 +00:00
This commit is contained in:
Richy 2025-07-03 14:31:01 +02:00 committed by GitHub
commit 25ffbc6a8a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1924,11 +1924,24 @@ impl CipherSyncData {
// Generate a HashMap with the collections_uuid as key and the CollectionGroup record // Generate a HashMap with the collections_uuid as key and the CollectionGroup record
let user_collections_groups: HashMap<CollectionId, CollectionGroup> = if CONFIG.org_groups_enabled() { let user_collections_groups: HashMap<CollectionId, CollectionGroup> = if CONFIG.org_groups_enabled() {
CollectionGroup::find_by_user(user_id, conn) let all_user_collection_groups = CollectionGroup::find_by_user(user_id, conn).await;
.await let mut combined_permissions: HashMap<CollectionId, CollectionGroup> = HashMap::new();
.into_iter()
.map(|collection_group| (collection_group.collections_uuid.clone(), collection_group)) for cg in all_user_collection_groups {
.collect() match combined_permissions.get_mut(&cg.collections_uuid) {
Some(existing) => {
// Combine permissions by taking the most permissive settings
existing.read_only = existing.read_only && cg.read_only; // false if ANY group allows write
existing.hide_passwords = existing.hide_passwords && cg.hide_passwords; // false if ANY group allows password view
existing.manage = existing.manage || cg.manage; // true if ANY group allows manage
}
None => {
// First group for this collection
combined_permissions.insert(cg.collections_uuid.clone(), cg);
}
}
}
combined_permissions
} else { } else {
HashMap::new() HashMap::new()
}; };