Spiegel von
https://github.com/dani-garcia/vaultwarden.git
synchronisiert 2025-01-07 11:45:40 +01:00
add to_json_details_for_user
Dieser Commit ist enthalten in:
Ursprung
23ef84d5e5
Commit
493d62188f
2 geänderte Dateien mit 13 neuen und 26 gelöschten Zeilen
|
@ -358,7 +358,7 @@ async fn get_org_collections_details(
|
|||
let users: Vec<Value> = col_users
|
||||
.iter()
|
||||
.filter(|collection_user| collection_user.collection_uuid == col.uuid)
|
||||
.map(|collection_user| UserSelection::to_collection_user_details_read_only(collection_user).to_json())
|
||||
.map(|collection_user| collection_user.to_json_details_for_user())
|
||||
.collect();
|
||||
|
||||
// get the group details for the given collection
|
||||
|
@ -660,9 +660,7 @@ async fn get_org_collection_detail(
|
|||
CollectionUser::find_by_collection_swap_user_uuid_with_member_uuid(&collection.uuid, &mut conn)
|
||||
.await
|
||||
.iter()
|
||||
.map(|collection_user| {
|
||||
UserSelection::to_collection_user_details_read_only(collection_user).to_json()
|
||||
})
|
||||
.map(|collection_user| collection_user.to_json_details_for_user())
|
||||
.collect();
|
||||
|
||||
let assigned = Collection::can_access_collection(&member, &collection.uuid, &mut conn).await;
|
||||
|
@ -2387,28 +2385,6 @@ impl CollectionSelection {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct UserSelection {
|
||||
id: UserId,
|
||||
read_only: bool,
|
||||
hide_passwords: bool,
|
||||
}
|
||||
|
||||
impl UserSelection {
|
||||
pub fn to_collection_user_details_read_only(collection_user: &CollectionUser) -> Self {
|
||||
Self {
|
||||
id: collection_user.user_uuid.clone(),
|
||||
read_only: collection_user.read_only,
|
||||
hide_passwords: collection_user.hide_passwords,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn to_json(&self) -> Value {
|
||||
json!(self)
|
||||
}
|
||||
}
|
||||
|
||||
#[post("/organizations/<org_id>/groups/<group_id>", data = "<data>")]
|
||||
async fn post_group(
|
||||
org_id: OrganizationId,
|
||||
|
|
|
@ -779,6 +779,17 @@ impl CollectionCipher {
|
|||
}
|
||||
}
|
||||
|
||||
impl CollectionUser {
|
||||
pub fn to_json_details_for_user(&self) -> Value {
|
||||
json!({
|
||||
"id": self.user_uuid,
|
||||
"readOnly": self.read_only,
|
||||
"hidePasswords": self.hide_passwords,
|
||||
"manage": false
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(DieselNewType, FromForm, Clone, Debug, Hash, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct CollectionId(String);
|
||||
|
||||
|
|
Laden …
In neuem Issue referenzieren