mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-14 11:05:32 -04:00
Implement logout method on Client
This commit is contained in:
@@ -75,6 +75,9 @@ interface Client {
|
||||
|
||||
[Throws=ClientError]
|
||||
SessionVerificationController get_session_verification_controller();
|
||||
|
||||
[Throws=ClientError]
|
||||
void logout();
|
||||
};
|
||||
|
||||
callback interface RoomDelegate {
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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<logout::v3::Response> {
|
||||
let request = logout::v3::Request::new();
|
||||
self.send(request, None).await
|
||||
}
|
||||
}
|
||||
|
||||
// The http mocking library is not supported for wasm32
|
||||
|
||||
Reference in New Issue
Block a user