Skip to content

Commit 7285084

Browse files
committed
fixup! feat(ffi): Expose legacy SSO support infomation
1 parent 4179a82 commit 7285084

File tree

1 file changed

+19
-26
lines changed

1 file changed

+19
-26
lines changed

bindings/matrix-sdk-ffi/src/client.rs

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -335,16 +335,32 @@ impl Client {
335335
}
336336
};
337337

338-
let supports_password_login = self.supports_password_login().await.ok().unwrap_or(false);
339-
let supports_sso_login = self.supports_sso_login().await.ok().unwrap_or(false);
338+
let login_types = self.inner.matrix_auth().get_login_types().await.ok();
339+
let supports_password_login = login_types
340+
.as_ref()
341+
.map(|login_types| {
342+
login_types.flows.iter().any(|login_type| {
343+
matches!(login_type, get_login_types::v3::LoginType::Password(_))
344+
})
345+
})
346+
.unwrap_or(false);
347+
let supports_sso_login = login_types
348+
.as_ref()
349+
.map(|login_types| {
350+
login_types
351+
.flows
352+
.iter()
353+
.any(|login_type| matches!(login_type, get_login_types::v3::LoginType::Sso(_)))
354+
})
355+
.unwrap_or(false);
340356
let sliding_sync_version = self.sliding_sync_version();
341357

342358
Arc::new(HomeserverLoginDetails {
343359
url: self.homeserver(),
344360
sliding_sync_version,
345361
supports_oidc_login,
346-
supports_sso_login,
347362
supported_oidc_prompts,
363+
supports_sso_login,
348364
supports_password_login,
349365
})
350366
}
@@ -735,29 +751,6 @@ impl Client {
735751
}
736752
}
737753

738-
impl Client {
739-
/// Whether or not the client's homeserver supports the password login flow.
740-
pub(crate) async fn supports_password_login(&self) -> anyhow::Result<bool> {
741-
let login_types = self.inner.matrix_auth().get_login_types().await?;
742-
let supports_password = login_types
743-
.flows
744-
.iter()
745-
.any(|login_type| matches!(login_type, get_login_types::v3::LoginType::Password(_)));
746-
Ok(supports_password)
747-
}
748-
749-
/// Whether or not the client's homeserver supports the legacy SSO login
750-
/// flow.
751-
pub(crate) async fn supports_sso_login(&self) -> anyhow::Result<bool> {
752-
let login_types = self.inner.matrix_auth().get_login_types().await?;
753-
let supports_password = login_types
754-
.flows
755-
.iter()
756-
.any(|login_type| matches!(login_type, get_login_types::v3::LoginType::Sso(_)));
757-
Ok(supports_password)
758-
}
759-
}
760-
761754
#[matrix_sdk_ffi_macros::export]
762755
impl Client {
763756
/// The sliding sync version.

0 commit comments

Comments
 (0)