Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Treat pending passkey verification as a value, not an error

Manav Rathia32fff40c128
diff --git a/rust/bindings/wasm/ente-wasm/src/auth.rs b/rust/bindings/wasm/ente-wasm/src/auth.rs
index 79f16721c2..6471cc56c2 100644
--- a/rust/bindings/wasm/ente-wasm/src/auth.rs
+++ b/rust/bindings/wasm/ente-wasm/src/auth.rs
@@ -45,7 +45,6 @@ impl From<ente_accounts::Error> for AccountsError {
E::IncorrectTotp => "incorrect_totp",
E::TotpRateLimited => "totp_rate_limited",
E::SecondFactorSessionExpired => "second_factor_session_expired",
- E::PasskeyVerificationPending => "passkey_verification_pending",
E::SessionInvalid => "session_invalid",
E::MissingKeyAttributes => "missing_key_attributes",
E::AccountAlreadyExists => "account_already_exists",
diff --git a/rust/crates/accounts/src/client.rs b/rust/crates/accounts/src/client.rs
index f925f0b635..ff0af29dce 100644
--- a/rust/crates/accounts/src/client.rs
+++ b/rust/crates/accounts/src/client.rs
@@ -503,9 +503,9 @@ impl AccountsClient {
.await?)
}
- pub async fn check_passkey_status(&self, session_id: &str) -> Result<AuthResponse> {
+ pub async fn check_passkey_status(&self, session_id: &str) -> Result<Option<AuthResponse>> {
let query = [("sessionID", session_id.to_string())];
- http::retry(|| async {
+ match http::retry(|| async {
self.api
.get("/users/two-factor/passkeys/get-token")
.query(&query)
@@ -517,11 +517,14 @@ impl AccountsClient {
.await
})
.await
- .map_err(|error| match error.status_code() {
- Some(400) => Error::PasskeyVerificationPending,
- Some(404 | 410) => Error::SecondFactorSessionExpired,
- _ => error.into(),
- })
+ {
+ Ok(response) => Ok(Some(response)),
+ Err(error) => match error.status_code() {
+ Some(400) => Ok(None),
+ Some(404 | 410) => Err(Error::SecondFactorSessionExpired),
+ _ => Err(error.into()),
+ },
+ }
}
pub async fn get_accounts_token(&self) -> Result<AccountsTokenResponse> {
diff --git a/rust/crates/accounts/src/error.rs b/rust/crates/accounts/src/error.rs
index edd50dd09b..3186b8f277 100644
--- a/rust/crates/accounts/src/error.rs
+++ b/rust/crates/accounts/src/error.rs
@@ -59,9 +59,6 @@ pub enum Error {
#[error("Second factor session expired. Please restart login.")]
SecondFactorSessionExpired,
- #[error("Passkey verification is pending")]
- PasskeyVerificationPending,
-
#[error("Session is invalid")]
SessionInvalid,
diff --git a/rust/crates/accounts/src/flow.rs b/rust/crates/accounts/src/flow.rs
index 5b4f4d8ab5..32e9730ba5 100644
--- a/rust/crates/accounts/src/flow.rs
+++ b/rust/crates/accounts/src/flow.rs
@@ -526,7 +526,7 @@ where
self.client.get_accounts_token().await
}
- pub async fn check_passkey_status(&self, session_id: &str) -> Result<AuthResponse> {
+ pub async fn check_passkey_status(&self, session_id: &str) -> Result<Option<AuthResponse>> {
self.client.check_passkey_status(session_id).await
}
@@ -727,10 +727,8 @@ where
loop {
self.ui.wait_for_passkey_verification()?;
- match self.client.check_passkey_status(passkey_session_id).await {
- Ok(result) => return Ok(result),
- Err(Error::PasskeyVerificationPending) => {}
- Err(error) => return Err(error),
+ if let Some(response) = self.client.check_passkey_status(passkey_session_id).await? {
+ return Ok(response);
}
}
}