1
0
Fork 0
Sometimes an org-uuid is not within the path but in a query value,
This fixes the check for that.
Dieser Commit ist enthalten in:
BlackDex 2020-03-19 16:50:47 +01:00
Ursprung b85d548879
Commit 669b101e6a

Datei anzeigen

@ -315,9 +315,28 @@ impl<'a, 'r> FromRequest<'a, 'r> for OrgHeaders {
Outcome::Forward(_) => Outcome::Forward(()), Outcome::Forward(_) => Outcome::Forward(()),
Outcome::Failure(f) => Outcome::Failure(f), Outcome::Failure(f) => Outcome::Failure(f),
Outcome::Success(headers) => { Outcome::Success(headers) => {
// org_id is expected to be the second param ("/organizations/<org_id>") // org_id is usually the second param ("/organizations/<org_id>")
match request.get_param::<String>(1) { // But there are cases where it is located in a query value.
Some(Ok(org_id)) => { // First check the param, if this is not a valid uuid, we will try the query value.
let query_org_id = match request.get_query_value::<String>("organizationId") {
Some(Ok(query_org_id)) => { query_org_id }
_ => { "".into() }
};
let param_org_id = match request.get_param::<String>(1) {
Some(Ok(param_org_id)) => { param_org_id }
_ => { "".into() }
};
let org_uuid: _ = match uuid::Uuid::parse_str(&param_org_id) {
Ok(uuid) => uuid,
_ => match uuid::Uuid::parse_str(&query_org_id) {
Ok(uuid) => uuid,
_ => err_handler!("Error getting the organization id"),
}
};
let org_id: &str = &org_uuid.to_string();
if !org_id.is_empty() {
let conn = match request.guard::<DbConn>() { let conn = match request.guard::<DbConn>() {
Outcome::Success(conn) => conn, Outcome::Success(conn) => conn,
_ => err_handler!("Error getting DB"), _ => err_handler!("Error getting DB"),
@ -348,8 +367,8 @@ impl<'a, 'r> FromRequest<'a, 'r> for OrgHeaders {
} }
}, },
}) })
} } else {
_ => err_handler!("Error getting the organization id"), err_handler!("Error getting the organization id")
} }
} }
} }