Browse Source

respect groups when deleting & adding collections

pull/2667/head
MFijak 3 years ago
committed by Maximilian Fijak
parent
commit
c08f89384c
  1. 5
      src/api/core/organizations.rs
  2. 3
      src/db/models/collection.rs

5
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.

3
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)))

Loading…
Cancel
Save