-
Notifications
You must be signed in to change notification settings - Fork 1
feat(platform): give AuthState::LoginFailed a typed kind #401
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,9 @@ | |
| use std::sync::{Arc, Mutex}; | ||
|
|
||
| use futures::channel::oneshot; | ||
| use truapi_platform::{AuthPresenter, AuthState, Platform, SessionUiInfo}; | ||
| use truapi_platform::{AuthPresenter, AuthState, LoginFailureKind, Platform, SessionUiInfo}; | ||
|
|
||
| use crate::runtime::login_failure::classify_login_failure; | ||
|
|
||
| /// Serialized auth-state machine bound to the platform's `auth_state_changed` | ||
| /// sink. Each transition mutates under the lock, releases it, then emits the | ||
|
|
@@ -71,6 +73,8 @@ impl AuthStateMachine { | |
| } | ||
|
|
||
| /// Active login -> `LoginFailed`: the in-flight login reported a failure. | ||
| /// The kind is recovered from `reason`, which is the only form the wallet | ||
| /// reports a refusal in. | ||
| pub(super) fn login_failed(&self, reason: String) { | ||
| self.transition(|inner| { | ||
| if !matches!( | ||
|
|
@@ -80,7 +84,10 @@ impl AuthStateMachine { | |
| return None; | ||
| } | ||
| inner.cancel_tx = None; | ||
| inner.state = AuthState::LoginFailed { reason }; | ||
| inner.state = AuthState::LoginFailed { | ||
| kind: classify_login_failure(&reason), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The classifier has three tests, but nothing tests that it is called here, or that |
||
| reason, | ||
| }; | ||
| Some(()) | ||
| }); | ||
| } | ||
|
|
@@ -97,7 +104,12 @@ impl AuthStateMachine { | |
| ) { | ||
| return None; | ||
| } | ||
| inner.state = AuthState::LoginFailed { reason }; | ||
| // Pre-pairing failures are the pairing host's own (device identity, | ||
| // bootstrap); allowance exhaustion is only ever wallet-reported. | ||
| inner.state = AuthState::LoginFailed { | ||
| kind: LoginFailureKind::Other, | ||
| reason, | ||
| }; | ||
| Some(()) | ||
| }); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that one kind is deterministic for the rest of the period, the host-facing docs that call
LoginFailedretryable are wrong. Could you add a clause to each saying it is retryable unlesskindisNoFreeAllowanceSlots:rust/crates/truapi-server/src/native.rsline 423 (LoginFailedas a retryable error),ios/truapi-host/Sources/TrUAPIHost/TrUAPIHost.swiftline 377,ios/truapi-host/README.mdline 150,android/truapi-host/src/main/kotlin/io/parity/truapi/TrUAPIHost.ktline 263, andandroid/truapi-host/README.mdline 165. The two copies in the generatedtruapi_server.swiftcome from thenative.rsdoc, so they follow from the bindings sync.