diff --git a/src/api/core/organizations.rs b/src/api/core/organizations.rs index 3e0878b9..98134ce7 100644 --- a/src/api/core/organizations.rs +++ b/src/api/core/organizations.rs @@ -299,6 +299,11 @@ async fn post_organization_collections( let collection = Collection::new(org.uuid, data.Name); collection.save(&conn).await?; + for group in data.Groups { + CollectionGroup::new(collection.uuid.clone(), group.Id, group.ReadOnly, group.HidePasswords) + .save(&conn).await?; + } + // If the user doesn't have access to all collections, only in case of a Manger, // then we need to save the creating user uuid (Manager) to the users_collection table. // Else the user will not have access to his own created collection. diff --git a/src/db/models/collection.rs b/src/db/models/collection.rs index e7e5acbb..ef17a3ed 100644 --- a/src/db/models/collection.rs +++ b/src/db/models/collection.rs @@ -1,6 +1,6 @@ use serde_json::Value; -use super::{User, UserOrgStatus, UserOrgType, UserOrganization}; +use super::{User, UserOrgStatus, UserOrgType, UserOrganization, CollectionGroup}; db_object! { #[derive(Identifiable, Queryable, Insertable, AsChangeset)] @@ -127,6 +127,7 @@ impl Collection { self.update_users_revision(conn).await; CollectionCipher::delete_all_by_collection(&self.uuid, conn).await?; CollectionUser::delete_all_by_collection(&self.uuid, conn).await?; + CollectionGroup::delete_all_by_collection(&self.uuid, &conn).await?; db_run! { conn: { diesel::delete(collections::table.filter(collections::uuid.eq(self.uuid)))