Implement logout method on Client

This commit is contained in:
ismailgulek
2022-09-06 15:56:14 +03:00
parent 5adec41b6b
commit 42767968ec
3 changed files with 18 additions and 1 deletions

View File

@@ -75,6 +75,9 @@ interface Client {
[Throws=ClientError]
SessionVerificationController get_session_verification_controller();
[Throws=ClientError]
void logout();
};
callback interface RoomDelegate {

View File

@@ -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]

View File

@@ -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