-
Notifications
You must be signed in to change notification settings - Fork 1.9k
fix(auth): handle system back press in phone auth flow #2418
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -16,6 +16,7 @@ package com.firebase.ui.auth.ui.screens.phone | |||||
|
|
||||||
| import android.content.Context | ||||||
| import android.util.Log | ||||||
| import androidx.activity.compose.BackHandler | ||||||
| import androidx.activity.compose.LocalActivity | ||||||
| import androidx.compose.runtime.Composable | ||||||
| import androidx.compose.runtime.LaunchedEffect | ||||||
|
|
@@ -340,6 +341,8 @@ fun PhoneAuthScreen( | |||||
| } | ||||||
| ) | ||||||
|
|
||||||
| BackHandler { onCancel() } | ||||||
|
|
||||||
| if (content != null) { | ||||||
| content(state) | ||||||
| } else { | ||||||
|
|
@@ -372,6 +375,7 @@ private fun DefaultPhoneAuthContent( | |||||
| } | ||||||
|
|
||||||
| PhoneAuthStep.EnterVerificationCode -> { | ||||||
| BackHandler { state.onChangeNumberClick() } | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similarly, the back handler on the verification code screen should be disabled while a verification request is in progress (
Suggested change
|
||||||
| EnterVerificationCodeUI( | ||||||
| configuration = configuration, | ||||||
| isLoading = state.isLoading, | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To prevent race conditions or inconsistent states, the back button should be disabled while an authentication operation is in progress (
isLoadingis true). If the user is allowed to navigate back or cancel while a network request is active, the background task might still succeed or fail later, leading to unexpected state transitions (e.g., suddenly logging in the user or showing an error dialog after they have already navigated away).