[fractal/fractal-next] AuthDialog: Make authenticate() more generic
- From: Julian Sparber <jsparber src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [fractal/fractal-next] AuthDialog: Make authenticate() more generic
- Date: Wed, 27 Oct 2021 13:24:26 +0000 (UTC)
commit 0dc85869e146f040d7cc1ccd28fb1ed06c909a77
Author: Julian Sparber <julian sparber net>
Date: Thu Oct 14 16:41:34 2021 +0200
AuthDialog: Make authenticate() more generic
src/components/auth_dialog.rs | 21 +++++++--------------
src/session/account_settings/devices_page/device.rs | 8 +++-----
2 files changed, 10 insertions(+), 19 deletions(-)
---
diff --git a/src/components/auth_dialog.rs b/src/components/auth_dialog.rs
index 009cf264..cbd4bad4 100644
--- a/src/components/auth_dialog.rs
+++ b/src/components/auth_dialog.rs
@@ -23,12 +23,10 @@ use matrix_sdk::{
},
},
error::{FromHttpResponseError, ServerError},
- OutgoingRequest,
},
ruma::assign,
- HttpError,
+ Error,
HttpError::UiaaError,
- HttpResult,
};
use std::fmt::Debug;
@@ -215,18 +213,13 @@ impl AuthDialog {
}
pub async fn authenticate<
- Request: Send + 'static,
- F1: Future<Output = HttpResult<Request::IncomingResponse>> + Send + 'static,
- FN: Fn(Option<AuthData>) -> F1 + Send + Sync + 'static + Clone,
+ Response: Send + 'static,
+ F1: Future<Output = Result<Response, Error>> + Send + 'static,
+ FN: Fn(Option<AuthData>) -> F1 + Send + 'static + Sync + Clone,
>(
&self,
callback: FN,
- ) -> Option<HttpResult<Request::IncomingResponse>>
- where
- Request: OutgoingRequest + Debug,
- Request::IncomingResponse: Send,
- HttpError: From<FromHttpResponseError<Request::EndpointError>>,
- {
+ ) -> Option<Result<Response, Error>> {
let priv_ = imp::AuthDialog::from_instance(self);
let mut auth_data = None;
@@ -237,9 +230,9 @@ impl AuthDialog {
let uiaa_info: UiaaInfo = match response {
Ok(result) => return Some(Ok(result)),
- Err(UiaaError(FromHttpResponseError::Http(ServerError::Known(
+ Err(Error::Http(UiaaError(FromHttpResponseError::Http(ServerError::Known(
UiaaResponse::AuthResponse(uiaa_info),
- )))) => uiaa_info,
+ ))))) => uiaa_info,
Err(error) => return Some(Err(error)),
};
diff --git a/src/session/account_settings/devices_page/device.rs
b/src/session/account_settings/devices_page/device.rs
index 16d7bb05..bddd20bb 100644
--- a/src/session/account_settings/devices_page/device.rs
+++ b/src/session/account_settings/devices_page/device.rs
@@ -195,19 +195,17 @@ impl Device {
if let Some(auth) = auth_data {
let auth = Some(auth.as_matrix_auth_data());
let request = assign!(delete_device::Request::new(&device_id), { auth });
- client.send(request, None).await
+ client.send(request, None).await.map_err(Into::into)
} else {
let request = delete_device::Request::new(&device_id);
- client.send(request, None).await
+ client.send(request, None).await.map_err(Into::into)
}
}
};
let dialog = AuthDialog::new(transient_for, &session);
- let result = dialog
- .authenticate::<delete_device::Request, _, _>(delete_fn)
- .await;
+ let result = dialog.authenticate(delete_fn).await;
match result {
Some(Ok(_)) => true,
Some(Err(err)) => {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]