omi icon indicating copy to clipboard operation
omi copied to clipboard

iOS Apple sign-in clears the current session before credentials are obtained and treats cancellation as failure

Open Itaxh1 opened this issue 2 months ago • 0 comments

Product impact

Primary loop layer: UX-Polish. Cancelling an authentication attempt should not destroy an existing session or display a sign-in failure for an intentional cancellation.

Verification scope

Revalidated against freshly fetched upstream main at d1fdcb4cc4fbd021eac799630e476f144e6bc18a (2026-09-23). Relevant source blobs were checked against the audited checkout. The fault-injection/device steps below are the proposed reproduction and regression checks; they were not executed during this audit. Store-release exposure and affected-user counts are UNKNOWN.

Current behavior and evidence

This is the native iOS path, selected only when USE_WEB_AUTH is false (app/lib/providers/auth_provider.dart:204); the code default is false, but store-build configuration is not established here. The native mobile Apple path calls handleAuthUserChanged(null) and awaits Firebase sign-out before requesting Apple credentials (app/lib/services/auth_service.dart:226). Its error path returns null (app/lib/services/auth_service.dart:282), and the provider maps a null result to failed-sign-in copy (app/lib/providers/auth_provider.dart:198).

The ordering is confirmed. Loss of an existing session is conditional on this method being invoked with a current user; this report does not claim that every normal first-run sign-in has an existing session, or that all Apple/Google review complaints have this cause.

Reproduction

  1. Exercise the production Apple sign-in path with a controlled auth boundary seeded with an existing user.
  2. Make the credential request return Apple's cancellation outcome.
  3. Assert that the current implementation has already called sign-out and cleared the local auth projection before that outcome arrives.
  4. Independently test a signed-out user cancelling the sheet: cancellation currently becomes generic failure feedback.
  5. Verify the sheet cancellation/retry UX on a physical iPhone; record the exact build and whether a user was signed in beforehand.

Proposed fix

Represent cancellation separately from provider/network/configuration/credential failures. Delay destructive session replacement until the new sign-in can be committed, respecting the existing account-cutover and cache-clearing owner. Do not clear a valid session merely to display the Apple sheet. Treat cancellation as neutral; preserve real failures as actionable errors. Keep duplicate-tap protection and reset loading on every terminal outcome.

Acceptance criteria

  • [ ] Cancellation before credential acquisition does not sign out an existing user or clear their local session state.
  • [ ] Signed-out cancellation returns to an interactive sign-in screen without an error toast.
  • [ ] Network, provider and token failures have bounded, useful recovery copy; credentials and tokens never enter logs.
  • [ ] A successful account change still executes the existing account-boundary cleanup; prior-user state cannot leak.
  • [ ] Tests cover existing-user cancellation, signed-out cancellation, provider failure, Firebase failure, success and a retry after each terminal outcome.

Duplicate/fix check

Closed #438 concerned a spinner/button remaining stuck after Apple-sheet dismissal. This is the still-present pre-credential sign-out and cancellation classification path, not a claim that the historical spinner fix is missing. Open onboarding redesign #12912 says production sign-in is unchanged; its inspected auth patches do not change this method. No equivalent open issue or fixing PR was found in the targeted search.

Additional duplicate check on 2026-09-23: #13689 and #13691 are closed community-signal aggregates with no demonstrated mapping to this cancellation path. No claim is made that this explains those reviews. Open #12912 at b43b1b499a20ea3265f4b273651355a7d76e22e2 was inspected; its auth diff adds local-emulator sign-in and leaves native Apple credential acquisition unchanged.

Itaxh1 avatar Sep 23 '26 22:09 Itaxh1