fix(auth): report Google/Facebook/OAuth/Anonymous sign-in failures via onSignInFailure - #2433
fix(auth): report Google/Facebook/OAuth/Anonymous sign-in failures via onSignInFailure#2433demolaf wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces an onSignInFailure callback to various authentication provider handlers (Anonymous, Facebook, Google, and OAuth) and propagates it through the UI and screens to report sign-in failures immediately. While the implementation and accompanying unit tests are solid, there are critical issues regarding Compose state management. Specifically, several remember and DisposableEffect blocks capture the new callback and other dependencies (like context and activity) without including them in their keys. This can lead to stale state captures, memory leaks (particularly with Activity references), and potential crashes. Updating these blocks to include all captured dependencies as keys is highly recommended.
…a onSignInFailure
…ymous/OAuth/Facebook sign-in handlers
5c54629 to
c3c78bb
Compare
FirebaseAuthScreen'sonSignInFailurecallback was only ever invoked fromEmailAuthScreenandPhoneAuthScreen's own effects. Google, Facebook, OAuth (Apple/Github/Microsoft/Yahoo/Twitter/generic), and Anonymous sign-in failures only updated the sharedAuthState.Error- which the top-level dialog controller shows - but never reachedonSignInFailure, so a consuming app's own error logging/analytics wired through that callback silently never fired for those providers.Threads an
onSignInFailurecallback into all fourremember*SignInHandlerfunctions, calling it alongside each existingupdateAuthState(AuthState.Error(...))so each provider reports its own failure exactly once, at the source - symmetric with how Email/Phone already report theirs.GoogleAuthProvider+FirebaseAuthUI.kt,FacebookAuthProvider+FirebaseAuthUI.kt,OAuthProvider+FirebaseAuthUI.kt,AnonymousAuthProvider+FirebaseAuthUI.kt: added anonSignInFailureparameter to eachremember*Handler, called in their catch blocks.FirebaseAuthScreen.kt: threadsonSignInFailurethroughrememberOnProviderSelectedand its two call sites - the main flow passes the real callback; the reauth sheet keeps its existing no-op default, matching how it already no-ops Email/Phone'sonErrorthere.Added direct tests forcing a failure (
testCredentialManagerProviderfor Google, a failingsignInAnonymously()task for Anonymous) confirmingonSignInFailurefires immediately without navigating anywhere - verified both are load-bearing by temporarily reverting the fix and confirming they fail.