mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-05-26 20:49:55 +00:00
refactor: Fix errors in api/client/device.rs
This commit is contained in:
+17
-34
@@ -121,36 +121,28 @@ pub(crate) async fn delete_device_route(
|
|||||||
let sender_user = body.sender_user();
|
let sender_user = body.sender_user();
|
||||||
let appservice = body.appservice_info.as_ref();
|
let appservice = body.appservice_info.as_ref();
|
||||||
|
|
||||||
if appservice.is_some() {
|
// Appservices get to skip UIAA for this endpoint
|
||||||
debug!("Skipping UIAA for {sender_user} as this is from an appservice");
|
if appservice.is_none() {
|
||||||
services
|
// Prompt the user to confirm with their password using UIAA
|
||||||
.users
|
let _ = services
|
||||||
.remove_device(sender_user, &body.device_id)
|
.uiaa
|
||||||
.await;
|
.authenticate_password(&body.auth, Some(Identity::from_user_id(sender_user)))
|
||||||
|
.await?;
|
||||||
return Ok(delete_device::v3::Response::new());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prompt the user to confirm with their password using UIAA
|
|
||||||
let _ = services
|
|
||||||
.uiaa
|
|
||||||
.authenticate_password(&body.auth, Some(Identity::from_user_id(sender_user)))
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
services
|
services
|
||||||
.users
|
.users
|
||||||
.remove_device(sender_user, &body.device_id)
|
.remove_device(sender_user, &body.device_id)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
Ok(delete_device::v3::Response {})
|
Ok(delete_device::v3::Response::new())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # `POST /_matrix/client/v3/delete_devices`
|
/// # `POST /_matrix/client/v3/delete_devices`
|
||||||
///
|
///
|
||||||
/// Deletes the given list of devices.
|
/// Deletes the given list of devices.
|
||||||
///
|
///
|
||||||
/// - Requires UIAA to verify user password unless from an appservice with
|
/// - Requires UIAA to verify user password.
|
||||||
/// MSC4190 enabled.
|
|
||||||
///
|
///
|
||||||
/// For each device:
|
/// For each device:
|
||||||
/// - Invalidates access token
|
/// - Invalidates access token
|
||||||
@@ -165,27 +157,18 @@ pub(crate) async fn delete_devices_route(
|
|||||||
let sender_user = body.sender_user();
|
let sender_user = body.sender_user();
|
||||||
let appservice = body.appservice_info.as_ref();
|
let appservice = body.appservice_info.as_ref();
|
||||||
|
|
||||||
if appservice.is_some_and(|appservice| appservice.registration.device_management) {
|
// Appservices get to skip UIAA for this endpoint
|
||||||
debug!(
|
if appservice.is_none() {
|
||||||
"Skipping UIAA for {sender_user} as this is from an appservice and MSC4190 is \
|
// Prompt the user to confirm with their password using UIAA
|
||||||
enabled"
|
let _ = services
|
||||||
);
|
.uiaa
|
||||||
for device_id in &body.devices {
|
.authenticate_password(&body.auth, Some(Identity::from_user_id(sender_user)))
|
||||||
services.users.remove_device(sender_user, device_id).await;
|
.await?;
|
||||||
}
|
|
||||||
|
|
||||||
return Ok(delete_devices::v3::Response {});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prompt the user to confirm with their password using UIAA
|
|
||||||
let _ = services
|
|
||||||
.uiaa
|
|
||||||
.authenticate_password(&body.auth, Some(Identity::from_user_id(sender_user)))
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
for device_id in &body.devices {
|
for device_id in &body.devices {
|
||||||
services.users.remove_device(sender_user, device_id).await;
|
services.users.remove_device(sender_user, device_id).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(delete_devices::v3::Response {})
|
Ok(delete_devices::v3::Response::new())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user