Open
Description
Step 1: Are you in the right place?
For issues or feature requests related to the code in this repository file a GitHub issue.
Step 2: Describe your environment
- Android device: OPPO Reno5A
- Android OS version: Android12
- Google Play Services version: 22.1.2
- Firebase/Play Services SDK version: 33.6.0
- FirebaseUI version: 8.0.2
Step 3: Describe the problem:
I'm facing an issue with FirebaseUI auth using Google accounts.
I've set up a blocking function in Firebase functions to control which email addresses can sign up.
@identity_fn.before_user_created()
def email_filtering(
event: identity_fn.AuthBlockingEvent) -> identity_fn.BeforeCreateResponse | None:
user = event.data
if user.email is None or not "@example.com" in user.email:
raise https_fn.HttpsError(code=https_fn.FunctionsErrorCode.INVALID_ARGUMENT,
message="Unauthorized email")
The problem is when the function returns a 400 error, FirebaseAuthUIAuthenticationResult callback isn't being invoked in Android.
private val signIn: ActivityResultLauncher<Intent> =
registerForActivityResult(FirebaseAuthUIActivityResultContract(), this::onSignInResult)
override fun onStart() {
super.onStart()
if (Firebase.auth.currentUser == null) {
val signInIntent = AuthUI.getInstance()
.createSignInIntentBuilder()
.setTheme(R.style.LoginTheme)
.setAvailableProviders(listOf(
AuthUI.IdpConfig.GoogleBuilder().build(),
))
.build()
signIn.launch(signInIntent)
} else {
goToMainActivity()
}
}
private fun onSignInResult(result: FirebaseAuthUIAuthenticationResult) {
if (result.resultCode == RESULT_OK) {
Log.d(TAG, "onSignInResult(): Sign in succeed")
} else {
val response = result.idpResponse
if (response == null) {
Log.w(TAG, "onSignInResult(): Sign in canceled")
} else {
Log.w(TAG, "onSignInResult(): Sign in error", response.error)
}
}
goToMainActivity()
}
If the email is correct one, the sign-up process completes successfully.
Otherwise the function returns 400 error as intended, but FirebaseUI doesn't appear to be handling it appropriately.
Can you help me understand why this is happening and how to fix it?