From 61183d001c67fd32d0c6dda190e832f41f596bc5 Mon Sep 17 00:00:00 2001 From: Jeremy Lin Date: Wed, 22 Feb 2023 12:17:13 -0800 Subject: [PATCH] Fix vault item display in org vault view In the org vault view, the Bitwarden web vault currently tries to fetch the groups for an org regardless of whether it claims to have group support. If this errors out, no vault items are displayed. --- src/api/core/organizations.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/api/core/organizations.rs b/src/api/core/organizations.rs index 176bf631..38ff63b7 100644 --- a/src/api/core/organizations.rs +++ b/src/api/core/organizations.rs @@ -2056,11 +2056,13 @@ async fn _restore_organization_user( #[get("/organizations//groups")] async fn get_groups(org_id: String, _headers: ManagerHeadersLoose, mut conn: DbConn) -> JsonResult { - if !CONFIG.org_groups_enabled() { - err!("Group support is disabled"); - } - - let groups = Group::find_by_organization(&org_id, &mut conn).await.iter().map(Group::to_json).collect::(); + let groups = if CONFIG.org_groups_enabled() { + Group::find_by_organization(&org_id, &mut conn).await.iter().map(Group::to_json).collect::() + } else { + // The Bitwarden clients seem to call this API regardless of whether groups are enabled, + // so just act as if there are no groups. + Value::Array(Vec::new()) + }; Ok(Json(json!({ "Data": groups,