Skip to content

onSignInSuccess never called — AuthState.Success always emits result=null #2318

@joknu1

Description

@joknu1

Library version: firebase-ui-auth:10.0.0-beta02

Since View based solution is no longer maintained and my number one crash in production is listed among the other issues here, I thought I'd give the compose beta a shot.

I've let AI handle the description below - it seem to be clear enough:

What happens

onSignInSuccess is never called, even on a first-time fresh email/password sign-in with no prior session. Instead, the user sees the default "Signed in as / Manage two-factor auth / Sign out" screen with no way to proceed.

Root cause

In FirebaseAuthScreen.kt line 523:

  state.result?.let { result ->
      if (state.user.uid != lastSuccessfulUserId.value) {                                                                                                                                                                                                                                                 
          onSignInSuccess(result)                                                                                                                                                                                                                                                                         
      }                                                                                                                                                                                                                                                                                                   
  } 

onSignInSuccess is gated on result != null. However, authUI.authStateFlow() emits AuthState.Success(result=null, ...) even after a fresh sign-in completes. This is confirmed by the library's own debug log immediately after a successful email/password login:

Current state: AuthState.Success(result=null, user=..., isNewUser=false)

Navigation to AuthRoute.Success.route happens unconditionally (line 536–541) regardless of whether result is null, so the success screen always shows — but the caller's completion callback never fires.

How to reproduce

  1. Integrate FirebaseAuthScreen with only onSignInSuccess as the completion signal.
  2. Launch the app with no prior Firebase session.
  3. Sign in with email and password.
  4. onSignInSuccess is never called. The "Signed in as" screen is shown with no way to proceed.

Additional issue: tooltip auto-shows on the success screen

With isMfaEnabled = false in the configuration, the tooltip on the disabled "Manage two-factor auth" button auto-opens on every render because of:

  // FirebaseAuthScreen.kt line 760                                                                                                                                                                                                                                                                       
  state = rememberTooltipState(                             
      initialIsVisible = !configuration.isMfaEnabled
  )

!false = true, so the tooltip is immediately visible. This is unexpected — a disabled feature should not announce itself to the user unprompted.

Suggested fixes

  1. Primary: Call onSignInSuccess when AuthState.Success is reached regardless of whether result is null. Either pass a synthetic wrapper or add a separate onAlreadyAuthenticated: (FirebaseUser) -> Unit callback for the null-result case so callers can handle both paths with named, distinct callbacks.
  2. Secondary: Change initialIsVisible = !configuration.isMfaEnabled to initialIsVisible = false — or only show the tooltip on explicit user interaction, not on initial render.

Workaround used in the meantime

Providing authenticatedContent and calling the app's own sign-in completion logic from there when authState is AuthState.Success.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions