aboutsummaryrefslogtreecommitdiff
path: root/src/db/models/group.rs
diff options
context:
space:
mode:
authorMathijs van Veluw <[email protected]>2024-08-15 12:36:00 +0200
committerGitHub <[email protected]>2024-08-15 12:36:00 +0200
commit9e26014b4df65acc44ee2c0e94fada0914843ec3 (patch)
treef136251e17751083658ced84828a5b27bc491806 /src/db/models/group.rs
parent339612c917ce6e47ac79359c711e42ee18833123 (diff)
downloadvaultwarden-9e26014b4df65acc44ee2c0e94fada0914843ec3.tar.gz
vaultwarden-9e26014b4df65acc44ee2c0e94fada0914843ec3.zip
Fix manager in web-vault v2024.6.2 for collections (#4860)
The web-vault v2024.6.2 we use needs some extra information to allow managers to actually be able to manage collections. The v2024.6.2 web-vault has somewhat of a mixture of the newer roles and older manager roles. To at least fix this for the web-vault we bundle these changes will make the manager able to manage. For future web-vaults we would need a lot more changes to be done to fix this in a better way though. Fixes #4844
Diffstat (limited to 'src/db/models/group.rs')
-rw-r--r--src/db/models/group.rs16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/db/models/group.rs b/src/db/models/group.rs
index f6ccc710..6e2db088 100644
--- a/src/db/models/group.rs
+++ b/src/db/models/group.rs
@@ -1,3 +1,7 @@
+use super::{User, UserOrgType, UserOrganization};
+use crate::api::EmptyResult;
+use crate::db::DbConn;
+use crate::error::MapResult;
use chrono::{NaiveDateTime, Utc};
use serde_json::Value;
@@ -69,7 +73,7 @@ impl Group {
})
}
- pub async fn to_json_details(&self, conn: &mut DbConn) -> Value {
+ pub async fn to_json_details(&self, user_org_type: &i32, conn: &mut DbConn) -> Value {
let collections_groups: Vec<Value> = CollectionGroup::find_by_group(&self.uuid, conn)
.await
.iter()
@@ -77,7 +81,8 @@ impl Group {
json!({
"id": entry.collections_uuid,
"readOnly": entry.read_only,
- "hidePasswords": entry.hide_passwords
+ "hidePasswords": entry.hide_passwords,
+ "manage": *user_org_type == UserOrgType::Manager && !entry.read_only && !entry.hide_passwords
})
})
.collect();
@@ -122,13 +127,6 @@ impl GroupUser {
}
}
-use crate::db::DbConn;
-
-use crate::api::EmptyResult;
-use crate::error::MapResult;
-
-use super::{User, UserOrganization};
-
/// Database methods
impl Group {
pub async fn save(&mut self, conn: &mut DbConn) -> EmptyResult {