Skip to content

fix(auth): close sign-in screens once the user is signed in - #1438

Open
demolaf wants to merge 2 commits into
mainfrom
fix/clear-email-routes
Open

demolaf wants to merge 2 commits into
mainfrom
fix/clear-email-routes

Conversation

@demolaf

@demolaf demolaf commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

Opening an email sign-in link signs the user in but leaves the sheet on the email-link screen, so they see the send form again instead of the signed-in screen.

Changes

  • On sign-in, remove every pushed screen that only applies while signed out: sign-in, sign-up, email link, password recovery, phone verification and second-factor resolution.
  • Screens for a signed-in user (update password, MFA enrolment and management) stay. An exhaustive switch on AuthView decides, so a new route has to pick a side.
  • EmailRouteTests covers both sets and replaces the test that expected .passwordRecovery to stay. The sign-in wiring itself is shown by the recordings below.

Preview

Before

Expected: when a user wants to sign in with an email link, opening the link should take them straight to the signed-in screen.

email-link-before.mp4

After

email-link-after.mp4

Maintainer note: Fixes internal CPRN-673

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request refactors the navigation flow in FirebaseAuthSwiftUI by replacing the email-specific route removal with a more generic removeSignedOutRoutes() method. This is achieved by introducing an isSignedOutOnly property on AuthView to identify screens that are only relevant when signed out, updating AuthPickerContent to use this new method, and adding comprehensive unit tests. The review feedback suggests isolating the Navigator class and its corresponding test suite to @MainActor to ensure thread safety and compatibility with Swift 6 strict concurrency.

Comment on lines +188 to 190
func removeSignedOutRoutes() {
routes.removeAll(where: \.isSignedOutOnly)
}

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.

high

To ensure thread safety and full compatibility with Swift 6 strict concurrency, the Navigator class should be isolated to the @MainActor. Since Navigator is @Observable, manages UI navigation state, and is directly bound to a NavigationStack in AuthPickerContent, mutating its routes property from non-main actors can lead to data races and runtime warnings.

@testable import FirebaseAuthSwiftUI
import Testing

struct NavigatorTests {

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.

medium

Since Navigator manages UI navigation state and should be isolated to the @MainActor, the test suite NavigatorTests should also be marked with @MainActor to ensure all test cases run on the main thread and avoid concurrency warnings.

Suggested change
struct NavigatorTests {
@MainActor
struct NavigatorTests {

@demolaf
demolaf marked this pull request as ready for review November 18, 2026 14:34
@demolaf
demolaf added this pull request to stack #1439 November 18, 2026 15:44
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.

1 participant