fix(auth): stop showing error dialog when Google sign-in is cancelled - #2427
fix(auth): stop showing error dialog when Google sign-in is cancelled#2427demolaf wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds handling for GetCredentialCancellationException when a user dismisses the Credential Manager sheet during Google Sign-In, updating the authentication state to AuthState.Cancelled without throwing an exception. It also changes the visibility of getRecoveryMessage, getRecoveryActionText, and isRecoverable in ErrorRecoveryDialog.kt from private to internal, enabling direct testing and the removal of redundant helper methods in ErrorRecoveryDialogLogicTest.kt. There are no review comments, and I have no feedback to provide.
russellwheatley
left a comment
There was a problem hiding this comment.
One concern on where sheet dismiss lands in the state machine.
| // not an error, so it goes to AuthState.Cancelled instead of AuthState.Error. | ||
| // Swallow (don't rethrow) so rememberGoogleSignInHandler's catch block doesn't | ||
| // overwrite this state with AuthState.Error. | ||
| updateAuthState(AuthState.Cancelled) |
There was a problem hiding this comment.
Routing sheet dismiss to AuthState.Cancelled fixes the Compose path (no dialog, onSignInCancelled fires), but FirebaseAuthActivity finishes with RESULT_CANCELED on that state. So Activity / AuthFlowController consumers would leave the whole auth UI when the user just dismisses the Google sheet, rather than staying on the method picker.
Is that intentional? If those consumers should stay on the picker, this probably wants Idle (or similar) instead of Cancelled, and onSignInCancelled would need a different trigger for provider-level dismiss.
There was a problem hiding this comment.
there's a gap in the implementation, the AuthFlowController.cancel triggers AuthState.Cancelled and terminates the entire activity which means AuthState.Cancelled is doing multiple things.
Using AuthState.Idle doesn't convey that an operation was cancelled, so that's ruled out.
We can leave AuthState.Cancelled for when an operation is cancelled and introduce a new state e.g. AuthState.Finished for when AuthFlowController.cancel is invoked?
This would be a breaking change.
6e3ee84 to
19d1d61
Compare
Brings in beta04's AuthState.isNotification pattern; adds the missing override to the new AuthState.Finished state and its self-consuming FirebaseAuthScreen branch to match.
Fixes #2422.
Cancelling the Google sign-in Credential Manager sheet showed an "Authentication Error" dialog with the raw
GetCredentialCancellationExceptionmessage ("User cancelled the selector") as the button text, instead of returning silently viaAuthState.Cancelled.signInWithGoogleonly caughtkotlinx.coroutines.CancellationException, not the actual exception Credential Manager throws on dismissal, so it fell through to the generic error path.GoogleAuthProvider+FirebaseAuthUI.kt: catchesGetCredentialCancellationExceptionexplicitly and updatesAuthState.Cancelledwithout rethrowing, so the sign-in flow returns to the picker silently andonSignInCancelledfires.ErrorRecoveryDialog.kt:getRecoveryActionTextno longer uses the raw exception message as the button label forAuthCancelledException.Added a test covering the Credential Manager cancellation path, and fixed
ErrorRecoveryDialogLogicTestto exercise the real (now-internal) dialog logic functions instead of a stale duplicate that had drifted from the actual code.Preview
no-cancel-dialog.webm