Spiegel von
https://github.com/dani-garcia/vaultwarden.git
synchronisiert 2024-11-04 02:18:00 +01:00
Merge pull request #3315 from BlackDex/issue-3311
Fix web-vault Member UI show/edit/save
Dieser Commit ist enthalten in:
Commit
a13a5bd1d8
1 geänderte Dateien mit 22 neuen und 5 gelöschten Zeilen
|
@ -748,8 +748,6 @@ struct GetOrgUserData {
|
||||||
include_groups: Option<bool>,
|
include_groups: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
// includeCollections
|
|
||||||
// includeGroups
|
|
||||||
#[get("/organizations/<org_id>/users?<data..>")]
|
#[get("/organizations/<org_id>/users?<data..>")]
|
||||||
async fn get_org_users(
|
async fn get_org_users(
|
||||||
data: GetOrgUserData,
|
data: GetOrgUserData,
|
||||||
|
@ -1229,14 +1227,25 @@ async fn _confirm_invite(
|
||||||
save_result
|
save_result
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/organizations/<org_id>/users/<org_user_id>")]
|
#[get("/organizations/<org_id>/users/<org_user_id>?<data..>")]
|
||||||
async fn get_user(org_id: String, org_user_id: String, _headers: AdminHeaders, mut conn: DbConn) -> JsonResult {
|
async fn get_user(
|
||||||
|
org_id: String,
|
||||||
|
org_user_id: String,
|
||||||
|
data: GetOrgUserData,
|
||||||
|
_headers: AdminHeaders,
|
||||||
|
mut conn: DbConn,
|
||||||
|
) -> JsonResult {
|
||||||
let user = match UserOrganization::find_by_uuid_and_org(&org_user_id, &org_id, &mut conn).await {
|
let user = match UserOrganization::find_by_uuid_and_org(&org_user_id, &org_id, &mut conn).await {
|
||||||
Some(user) => user,
|
Some(user) => user,
|
||||||
None => err!("The specified user isn't a member of the organization"),
|
None => err!("The specified user isn't a member of the organization"),
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(Json(user.to_json_details(&mut conn).await))
|
// In this case, when groups are requested we also need to include collections.
|
||||||
|
// Else these will not be shown in the interface, and could lead to missing collections when saved.
|
||||||
|
let include_groups = data.include_groups.unwrap_or(false);
|
||||||
|
Ok(Json(
|
||||||
|
user.to_json_user_details(data.include_collections.unwrap_or(include_groups), include_groups, &mut conn).await,
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
|
@ -1244,6 +1253,7 @@ async fn get_user(org_id: String, org_user_id: String, _headers: AdminHeaders, m
|
||||||
struct EditUserData {
|
struct EditUserData {
|
||||||
Type: NumberOrString,
|
Type: NumberOrString,
|
||||||
Collections: Option<Vec<CollectionData>>,
|
Collections: Option<Vec<CollectionData>>,
|
||||||
|
Groups: Option<Vec<String>>,
|
||||||
AccessAll: bool,
|
AccessAll: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1342,6 +1352,13 @@ async fn edit_user(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GroupUser::delete_all_by_user(&user_to_edit.uuid, &mut conn).await?;
|
||||||
|
|
||||||
|
for group in data.Groups.iter().flatten() {
|
||||||
|
let mut group_entry = GroupUser::new(String::from(group), user_to_edit.uuid.clone());
|
||||||
|
group_entry.save(&mut conn).await?;
|
||||||
|
}
|
||||||
|
|
||||||
log_event(
|
log_event(
|
||||||
EventType::OrganizationUserUpdated as i32,
|
EventType::OrganizationUserUpdated as i32,
|
||||||
&user_to_edit.uuid,
|
&user_to_edit.uuid,
|
||||||
|
|
Laden …
In neuem Issue referenzieren