diff --git a/bindings/matrix-sdk-ffi/src/api.udl b/bindings/matrix-sdk-ffi/src/api.udl index d2c37d874..9662d9944 100644 --- a/bindings/matrix-sdk-ffi/src/api.udl +++ b/bindings/matrix-sdk-ffi/src/api.udl @@ -75,6 +75,9 @@ interface Client { [Throws=ClientError] SessionVerificationController get_session_verification_controller(); + + [Throws=ClientError] + void logout(); }; callback interface RoomDelegate { diff --git a/bindings/matrix-sdk-ffi/src/client.rs b/bindings/matrix-sdk-ffi/src/client.rs index 1537e614f..1d1d325cf 100644 --- a/bindings/matrix-sdk-ffi/src/client.rs +++ b/bindings/matrix-sdk-ffi/src/client.rs @@ -283,6 +283,14 @@ impl Client { Ok(Arc::new(session_verification_controller)) }) } + + /// Log out the current user + pub fn logout(&self) -> anyhow::Result<()> { + RUNTIME.block_on(async move { + _ = self.client.logout().await; + Ok(()) + }) + } } #[uniffi::export] diff --git a/crates/matrix-sdk/src/client/mod.rs b/crates/matrix-sdk/src/client/mod.rs index 3d5869460..285e8dff5 100644 --- a/crates/matrix-sdk/src/client/mod.rs +++ b/crates/matrix-sdk/src/client/mod.rs @@ -54,7 +54,7 @@ use ruma::{ membership::{join_room_by_id, join_room_by_id_or_alias}, push::get_notifications::v3::Notification, room::create_room, - session::{get_login_types, login, refresh_token, sso_login, sso_login_with_provider}, + session::{get_login_types, login, refresh_token, sso_login, sso_login_with_provider, logout}, sync::sync_events, uiaa::{AuthData, UserIdentifier}, }, @@ -2433,6 +2433,12 @@ impl Client { let request = whoami::v3::Request::new(); self.send(request, None).await } + + /// Log out the current user + pub async fn logout(&self) -> HttpResult { + let request = logout::v3::Request::new(); + self.send(request, None).await + } } // The http mocking library is not supported for wasm32