Skip to content

Commit

Permalink
Expose login with email + password on the client
Browse files Browse the repository at this point in the history
  • Loading branch information
zzorba authored and Hywan committed Aug 26, 2024
1 parent b9d49b8 commit 47671a1
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion bindings/matrix-sdk-ffi/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ use matrix_sdk_ui::notification_client::{
};
use mime::Mime;
use ruma::{
api::client::{alias::get_alias, discovery::discover_homeserver::AuthenticationServerInfo},
api::client::{
alias::get_alias, discovery::discover_homeserver::AuthenticationServerInfo,
uiaa::UserIdentifier,
},
events::{
ignored_user_list::IgnoredUserListEventContent,
room::power_levels::RoomPowerLevelsEventContent, GlobalAccountDataEventType,
Expand Down Expand Up @@ -290,6 +293,32 @@ impl Client {
Ok(())
}

/// Login using an email and password.
pub async fn login_with_email(
&self,
email: String,
password: String,
initial_device_name: Option<String>,
device_id: Option<String>,
) -> Result<(), ClientError> {
let mut builder = self
.inner
.matrix_auth()
.login_identifier(UserIdentifier::Email { address: email }, &password);

if let Some(initial_device_name) = initial_device_name.as_ref() {
builder = builder.initial_device_display_name(initial_device_name);
}

if let Some(device_id) = device_id.as_ref() {
builder = builder.device_id(device_id);
}

builder.send().await?;

Ok(())
}

/// Returns a handler to start the SSO login process.
pub(crate) async fn start_sso_login(
self: &Arc<Self>,
Expand Down

0 comments on commit 47671a1

Please sign in to comment.