firebase / firebaseui-web

FirebaseUI is an open-source JavaScript library for Web that provides simple, customizable UI bindings on top of Firebase SDKs to eliminate boilerplate code and promote best practices.
https://firebase.google.com/
Apache License 2.0
4.58k stars 1.06k forks source link

Setting languageCode for email verification does not appear to work #487

Open mhuebert opened 6 years ago

mhuebert commented 6 years ago

The docs say that one can set the language code for the email verification flow like so:

firebase.auth().languageCode = 'fr';
authResult.user.sendEmailVerification();

I can't seem to get this to work -- no matter what I do, the email and verification page remain in English. I have created a minimal reproduction using the following success callback:

signInSuccessWithAuthResult: function(authResult) {
  firebase.auth().languageCode = "fr";
  authResult.user.sendEmailVerification();
  return false
}

The verification email is sent, but the language remains English, instead of being set to french.

Minimal reproduction:

bojeil-google commented 6 years ago

Thanks for filing. I can recreate this. I suspect it may be an issue with updateCurrentUser.

bojeil-google commented 6 years ago

It is unrelated to FirebaseUI and the root cause is likely in the firebase-js-sdk.

bojeil-google commented 6 years ago

I think I jumped to the wrong conclusion. It appears to be the behavior in FirebaseUI. We call reset() after signInSuccess triggers which sets the original languageCode on the Auth instance overwriting your value. https://github.com/firebase/firebaseui-web/blob/master/javascript/widgets/authui.js#L671 There is a race condition here. By the time the email verification is sent, the original language code is set again (null in this case).

mhuebert commented 6 years ago

Thanks for looking into this. Yes, I can confirm that if I add a timeout of 0 (before I set the language code and trigger the email), the race condition is avoided and I am able to set the language.

filipef101 commented 5 years ago

Still happening, event with a 1 second timeout

bojeil-google commented 5 years ago

This should have been fixed in v3.4.1. Make sure to upgrade to 3.4.1+