firebase / firebase-android-sdk

Firebase Android SDK
https://firebase.google.com
Apache License 2.0
2.23k stars 565 forks source link

language locale is not set after calling `setLanguageCode` & appears as "und" in Auth blocking function. #5825

Open russellwheatley opened 3 months ago

russellwheatley commented 3 months ago

[READ] Step 1: Are you in the right place?

Yes, right place.

[REQUIRED] Step 2: Describe your environment

[REQUIRED] Step 3: Describe the problem

language locale in auth blocking function is "und" which means undetermined. This is occuring even when setting the language code.

First reported on FlutterFire repo: https://github.com/firebase/flutterfire/issues/12519

This is not an issue on firebas-ios-sdk.

Logcat shows why it is "und":

2024-04-03 09:50:57.889 26056-26147 System                  io.flutter.plugins.firebase.tests    W  Ignoring header X-Firebase-Locale because its value was null.

Steps to reproduce:

I have a repo with reproduction here: https://github.com/russellwheatley/firebase-android

Here are the steps taken from README:

  1. Update applicationId & namespace in app/build.gradle to your app in your firebase project.
  2. Update app/google-services.json to your firebase project.
  3. Run npm i in backend/functions directory followed by npm run deploy to deploy the cloud functions to your firebase project.
  4. Run the app on an emulator and press the button in the bottom right hand corner to set the language, create a user and trigger the cloud function.
  5. Head to the cloud function logs and observe the locale as authBeforeUserCreated {"locale":"und",....other properties}. This should be "en-US".

Relevant Code:

FirebaseApp app = FirebaseApp.getInstance();
            FirebaseAuth auth = FirebaseAuth.getInstance(app);

            auth.setLanguageCode("en-US");

            auth.createUserWithEmailAndPassword("test-email@testemail.com", "qwerty123").addOnCompleteListener(task -> {
                if (task.isSuccessful()) {
                    Log.d(TAG, "User created successfully");

                } else {
                    Log.d(TAG, "User creation failed");
                }
            });
lehcar09 commented 2 months ago

Hi @russellwheatley, thank you for reporting the issue. I was able to reproduce the issue with the MCVE you shared. I noticed that eventhough the locale shows und the verification email language is correct. I’ll notify our engineers and see what we can do here.

mauriciotogneri commented 3 weeks ago

Hi @lehcar09, any updates on this issue? Maybe a workaround?