From 04868cca36d313b3ecf9720ed9b8f19f3ccaade1 Mon Sep 17 00:00:00 2001 From: Stefan Melmuk Date: Fri, 17 Jan 2025 19:02:37 +0100 Subject: [PATCH] cleanup check for undefined token --- src/api/core/organizations.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/api/core/organizations.rs b/src/api/core/organizations.rs index 7b8638d3c5..aac9313931 100644 --- a/src/api/core/organizations.rs +++ b/src/api/core/organizations.rs @@ -1818,19 +1818,17 @@ async fn list_policies(org_id: OrganizationId, _headers: AdminHeaders, mut conn: #[get("/organizations//policies/token?")] async fn list_policies_token(org_id: OrganizationId, token: &str, mut conn: DbConn) -> JsonResult { - // web-vault 2024.6.2 seems to send these values and cause logs to output errors - // Catch this and prevent errors in the logs - // TODO: CleanUp after 2024.6.x is not used anymore. - if org_id.as_ref() == "undefined" && token == "undefined" || org_id.as_ref() == FAKE_ADMIN_UUID { - return Ok(Json(json!({}))); - } - let invite = decode_invite(token)?; if invite.org_id != org_id { err!("Token doesn't match request organization"); } + // exit early when we have been invited via /admin panel + if org_id.as_ref() == FAKE_ADMIN_UUID { + return Ok(Json(json!({}))); + } + // TODO: We receive the invite token as ?token=<>, validate it contains the org id let policies = OrgPolicy::find_by_org(&org_id, &mut conn).await; let policies_json: Vec = policies.iter().map(OrgPolicy::to_json).collect();