Skip to content

Commit

Permalink
Small changes for v2024.12.0
Browse files Browse the repository at this point in the history
Signed-off-by: BlackDex <[email protected]>
  • Loading branch information
BlackDex committed Dec 12, 2024
1 parent 026a208 commit 2fab77a
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 5 deletions.
21 changes: 17 additions & 4 deletions src/api/core/organizations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ pub fn routes() -> Vec<Route> {
restore_organization_user,
bulk_restore_organization_user,
get_groups,
get_groups_details,
post_groups,
get_group,
put_group,
Expand All @@ -99,6 +100,7 @@ pub fn routes() -> Vec<Route> {
get_org_export,
api_key,
rotate_api_key,
get_billing_metadata,
]
}

Expand Down Expand Up @@ -2012,6 +2014,12 @@ fn get_plans_tax_rates(_headers: Headers) -> Json<Value> {
Json(_empty_data_json())
}

#[get("/organizations/<_org_id>/billing/metadata")]
fn get_billing_metadata(_org_id: &str, _headers: Headers) -> Json<Value> {
// Prevent a 404 error, which also causes Javascript errors.
Json(_empty_data_json())
}

fn _empty_data_json() -> Value {
json!({
"object": "list",
Expand Down Expand Up @@ -2410,6 +2418,11 @@ async fn get_groups(org_id: &str, _headers: ManagerHeadersLoose, mut conn: DbCon
})))
}

#[get("/organizations/<org_id>/groups/details", rank = 1)]
async fn get_groups_details(org_id: &str, headers: ManagerHeadersLoose, conn: DbConn) -> JsonResult {
get_groups(org_id, headers, conn).await
}

#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
struct GroupRequest {
Expand Down Expand Up @@ -2595,13 +2608,13 @@ async fn add_update_group(
})))
}

#[get("/organizations/<_org_id>/groups/<group_id>/details")]
async fn get_group_details(_org_id: &str, group_id: &str, _headers: AdminHeaders, mut conn: DbConn) -> JsonResult {
#[get("/organizations/<org_id>/groups/<group_id>/details")]
async fn get_group_details(org_id: &str, group_id: &str, _headers: AdminHeaders, mut conn: DbConn) -> JsonResult {
if !CONFIG.org_groups_enabled() {
err!("Group support is disabled");
}

let group = match Group::find_by_uuid(group_id, &mut conn).await {
let group = match Group::find_by_uuid_and_org(group_id, org_id, &mut conn).await {
Some(group) => group,
_ => err!("Group could not be found!"),
};
Expand Down Expand Up @@ -2662,7 +2675,7 @@ async fn bulk_delete_groups(
Ok(())
}

#[get("/organizations/<_org_id>/groups/<group_id>")]
#[get("/organizations/<_org_id>/groups/<group_id>", rank = 2)]
async fn get_group(_org_id: &str, group_id: &str, _headers: AdminHeaders, mut conn: DbConn) -> JsonResult {
if !CONFIG.org_groups_enabled() {
err!("Group support is disabled");
Expand Down
11 changes: 11 additions & 0 deletions src/db/models/group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,17 @@ impl Group {
}}
}

pub async fn find_by_uuid_and_org(uuid: &str, org_uuid: &str, conn: &mut DbConn) -> Option<Self> {
db_run! { conn: {
groups::table
.filter(groups::uuid.eq(uuid))
.filter(groups::organizations_uuid.eq(org_uuid))
.first::<GroupDb>(conn)
.ok()
.from_db()
}}
}

pub async fn find_by_external_id_and_org(external_id: &str, org_uuid: &str, conn: &mut DbConn) -> Option<Self> {
db_run! { conn: {
groups::table
Expand Down
7 changes: 6 additions & 1 deletion src/static/templates/scss/vaultwarden.scss.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,12 @@ app-organization-plans > form > bit-section:nth-child(2) {

/* Hide Collection Management Form */
app-org-account form.ng-untouched:nth-child(6) {
display:none !important
@extend %vw-hide;
}

/* Hide 'Member Access' Report Card from Org Reports */
app-org-reports-home > app-report-list > div.tw-inline-grid > div:nth-child(6) > app-report-card:nth-child(1) {
@extend %vw-hide;
}

/* Hide Device Verification form at the Two Step Login screen */
Expand Down

0 comments on commit 2fab77a

Please sign in to comment.