1
0
Fork 0
mirror of https://github.com/dani-garcia/vaultwarden.git synced 2025-08-16 07:52:31 +00:00

prevent side effects if groups are disabled (#4265)

This commit is contained in:
Stefan Melmuk 2024-01-25 22:02:07 +01:00 committed by GitHub
commit 1b801406d6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 226 additions and 126 deletions

View file

@ -1788,15 +1788,22 @@ impl CipherSyncData {
.collect();
// Generate a HashMap with the collections_uuid as key and the CollectionGroup record
let user_collections_groups: HashMap<String, CollectionGroup> = CollectionGroup::find_by_user(user_uuid, conn)
.await
.into_iter()
.map(|collection_group| (collection_group.collections_uuid.clone(), collection_group))
.collect();
let user_collections_groups: HashMap<String, CollectionGroup> = if CONFIG.org_groups_enabled() {
CollectionGroup::find_by_user(user_uuid, conn)
.await
.into_iter()
.map(|collection_group| (collection_group.collections_uuid.clone(), collection_group))
.collect()
} else {
HashMap::new()
};
// Get all organizations that the user has full access to via group assignment
let user_group_full_access_for_organizations: HashSet<String> =
Group::gather_user_organizations_full_access(user_uuid, conn).await.into_iter().collect();
let user_group_full_access_for_organizations: HashSet<String> = if CONFIG.org_groups_enabled() {
Group::gather_user_organizations_full_access(user_uuid, conn).await.into_iter().collect()
} else {
HashSet::new()
};
Self {
cipher_attachments,