Skip to content

Commit

Permalink
Remove compatibility route (#4578)
Browse files Browse the repository at this point in the history
  • Loading branch information
Timshel authored May 25, 2024
1 parent f01ef40 commit 9555ac7
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions src/api/core/accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ pub fn routes() -> Vec<rocket::Route> {
api_key,
rotate_api_key,
get_known_device,
get_known_device_from_path,
put_avatar,
put_device_token,
put_clear_device_token,
Expand Down Expand Up @@ -979,22 +978,15 @@ async fn rotate_api_key(data: JsonUpcase<PasswordOrOtpData>, headers: Headers, c
_api_key(data, true, headers, conn).await
}

// This variant is deprecated: https://github.com/bitwarden/server/pull/2682
#[get("/devices/knowndevice/<email>/<uuid>")]
async fn get_known_device_from_path(email: &str, uuid: &str, mut conn: DbConn) -> JsonResult {
// This endpoint doesn't have auth header
#[get("/devices/knowndevice")]
async fn get_known_device(device: KnownDevice, mut conn: DbConn) -> JsonResult {
let mut result = false;
if let Some(user) = User::find_by_mail(email, &mut conn).await {
result = Device::find_by_uuid_and_user(uuid, &user.uuid, &mut conn).await.is_some();
if let Some(user) = User::find_by_mail(&device.email, &mut conn).await {
result = Device::find_by_uuid_and_user(&device.uuid, &user.uuid, &mut conn).await.is_some();
}
Ok(Json(json!(result)))
}

#[get("/devices/knowndevice")]
async fn get_known_device(device: KnownDevice, conn: DbConn) -> JsonResult {
get_known_device_from_path(&device.email, &device.uuid, conn).await
}

struct KnownDevice {
email: String,
uuid: String,
Expand Down

0 comments on commit 9555ac7

Please sign in to comment.