Skip to content

Bug 1868418 - Rerun ensure capabilities after logging in#7457

Open
bendk wants to merge 1 commit into
mozilla:mainfrom
bendk:bdk/push-ywlrwvrlttxo
Open

Bug 1868418 - Rerun ensure capabilities after logging in#7457
bendk wants to merge 1 commit into
mozilla:mainfrom
bendk:bdk/push-ywlrwvrlttxo

Conversation

@bendk

@bendk bendk commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Moved the code to RetryingAccount, which should give us this functionality for free.

Pull Request checklist

  • Breaking changes: This PR follows our breaking change policy
    • This PR follows the breaking change policy:
      • This PR has no breaking API changes, or
      • There are corresponding PRs for our consumer applications that resolve the breaking changes and have been approved
  • Quality: This PR builds and tests run cleanly
    • Note:
      • For changes that need extra cross-platform testing, consider adding [ci full] to the PR title.
      • If this pull request includes a breaking change, consider cutting a new release after merging.
  • Tests: This PR includes thorough tests or an explanation of why it does not
  • Changelog: This PR includes a changelog entry in CHANGELOG.md or an explanation of why it does not need one
    • Any breaking changes to Swift or Kotlin binding APIs are noted explicitly
  • Dependencies: This PR follows our dependency management guidelines
    • Any new dependencies are accompanied by a summary of the due diligence applied in selecting them.

@bendk bendk requested a review from skhamis June 30, 2026 15:29
@bendk

bendk commented Jun 30, 2026

Copy link
Copy Markdown
Contributor Author

I think I got the state machine stuff right, but please double-check my work here.

@bendk bendk force-pushed the bdk/push-ywlrwvrlttxo branch from 34eacc8 to 5fd30b9 Compare June 30, 2026 15:32
Moved the code to RetryingAccount, which should give us this
functionality for free.

Also, tweaked the fxa-client example a bit.
@bendk bendk force-pushed the bdk/push-ywlrwvrlttxo branch from 5fd30b9 to be1a391 Compare June 30, 2026 18:35

@skhamis skhamis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice fix! I think we're close but just one question about the error part

Ok(if active { S::Connected } else { S::AuthIssues })
}
match account.finish_initialize(&device_config.capabilities) {
Ok(()) => Ok(S::Connected),

@skhamis skhamis Jul 1, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing worth checking: in the old code we land at S::AuthIssues when check_authorization_status comes back false. The new code propagates the original FxaError::Authentication to the Err(cause) arm, which sends us to S::Disconnected?. For someone who is signed-in and whose refresh token is server-invalidated (password-changed elsewhere), I think our AuthIssues preserves the account state and lets consumers show the "re-auth" flow. Disconnected will put them back to full sign-in right?
Should we do something like:

 match account.finish_initialize(&device_config.capabilities) {
                         Ok(()) => Ok(S::Connected),
                        Err(cause) => {
                            let target = if matches!(cause.get_error_handling().err, FxaError::Authentication) {
                                S::AuthIssues
                            } else {
                                S::Disconnected
                            };
                            Err(StateMachineErr::new(cause, target))
                        }
                    }

or something similar? However if i'm missing something here please let me know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants