Skip to content

Commit 6b9828f

Browse files
wti806bojeil-google
authored andcommitted
Release (#336)
Fixes the verifyPassword error logged to the browser console on anonymous user upgrade. Fixes the bug when the incorrect user reference is returned on anonymous user upgrade which occurs when a user is already signed in on the external Auth instance. Fixes the uncaught promise cancellation error when signInSuccess callback is provided and no redirect is required.
1 parent 9ca77cd commit 6b9828f

File tree

9 files changed

+70
-12
lines changed

9 files changed

+70
-12
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,17 @@ Localized versions of the widget are available through the CDN. To use a localiz
6363
localized JS library instead of the default library:
6464

6565
```html
66-
<script src="https://www.gstatic.com/firebasejs/ui/2.6.1/firebase-ui-auth__{LANGUAGE_CODE}.js"></script>
67-
<link type="text/css" rel="stylesheet" href="https://www.gstatic.com/firebasejs/ui/2.6.1/firebase-ui-auth.css" />
66+
<script src="https://www.gstatic.com/firebasejs/ui/2.6.2/firebase-ui-auth__{LANGUAGE_CODE}.js"></script>
67+
<link type="text/css" rel="stylesheet" href="https://www.gstatic.com/firebasejs/ui/2.6.2/firebase-ui-auth.css" />
6868
```
6969

7070
where `{LANGUAGE_CODE}` is replaced by the code of the language you want. For example, the French
7171
version of the library is available at
72-
`https://www.gstatic.com/firebasejs/ui/2.6.1/firebase-ui-auth__fr.js`. The list of available
72+
`https://www.gstatic.com/firebasejs/ui/2.6.2/firebase-ui-auth__fr.js`. The list of available
7373
languages and their respective language codes can be found at [LANGUAGES.md](LANGUAGES.md).
7474

7575
Right-to-left languages also require the right-to-left version of the stylesheet, available at
76-
`https://www.gstatic.com/firebasejs/ui/2.6.1/firebase-ui-auth-rtl.css`, instead of the default
76+
`https://www.gstatic.com/firebasejs/ui/2.6.2/firebase-ui-auth-rtl.css`, instead of the default
7777
stylesheet. The supported right-to-left languages are Arabic (ar), Farsi (fa), and Hebrew (iw).
7878

7979
### Option 2: npm Module

changelog.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fixed - Fixes the verifyPassword error logged to the browser console on anonymous user upgrade.
2+
fixed - Fixes the bug when the incorrect user reference is returned on anonymous user upgrade which occurs when a user is already signed in on the external Auth instance.
3+
fixed - Fixes the uncaught promise cancellation error when signInSuccess callback is provided and no redirect is required.

javascript/widgets/authui.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1152,9 +1152,12 @@ firebaseui.auth.AuthUI.prototype.finishSignInWithCredential =
11521152
// Anonymous user upgrade successful, resolve immediately with the user.
11531153
// No need to sign in again with the same credential on the external Auth
11541154
// instance.
1155+
// If user is signed in on internal instance, ignore the user on external
1156+
// instance and finish the sign in on external instance.
11551157
if (self.currentUser_ &&
11561158
!self.currentUser_['isAnonymous'] &&
1157-
self.getConfig().autoUpgradeAnonymousUsers()) {
1159+
self.getConfig().autoUpgradeAnonymousUsers() &&
1160+
!self.getAuth().currentUser) {
11581161
return (firebase.Promise || goog.Promise).resolve(self.currentUser_);
11591162
} else if (user) {
11601163
// TODO: optimize and fail directly as this will fail in most cases

javascript/widgets/authui_test.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2909,6 +2909,46 @@ function testFinishSignInWithCredential_upgradeAnonymous_nonAnonymous() {
29092909
}
29102910

29112911

2912+
function testFinishSignInWithCredential_upgradeAnon_nonAnonUserOnTempAuth() {
2913+
// If there is a user signed in on internal instance, finish the sign in flow
2914+
// by signing it on external instance.
2915+
testApp = new firebaseui.auth.testing.FakeAppClient(options);
2916+
testAuth = testApp.auth();
2917+
app = new firebaseui.auth.AuthUI(testAuth, 'id0');
2918+
// Simulate autoUpgradeAnonymousUsers set to true.
2919+
app.setConfig(anonymousUpgradeConfig);
2920+
app.getAuth().install();
2921+
app.getExternalAuth().install();
2922+
asyncTestCase.waitForSignals(1);
2923+
var userOnExternalInstance = {
2924+
'email': '[email protected]',
2925+
'displayName': 'Federated User2'
2926+
};
2927+
// Simulate a user already logged in on external instance.
2928+
testAuth.setUser(userOnExternalInstance);
2929+
// Simulate another user already logged in on internal instance.
2930+
app.getAuth().setUser(expectedUser);
2931+
app.finishSignInWithCredential(expectedCredential)
2932+
.then(function(user) {
2933+
// The user returned should be the one originally signed in on internal
2934+
// instance.
2935+
assertObjectEquals(app.getAuth().currentUser, user);
2936+
assertEquals(app.getExternalAuth().currentUser, user);
2937+
asyncTestCase.signal();
2938+
});
2939+
// Trigger initial onAuthStateChanged listener.
2940+
app.getExternalAuth().runAuthChangeHandler();
2941+
app.getExternalAuth().assertSignInWithCredential(
2942+
[expectedCredential],
2943+
function() {
2944+
app.getExternalAuth().setUser(expectedUser);
2945+
return app.getExternalAuth().currentUser;
2946+
});
2947+
app.getExternalAuth().process();
2948+
app.getAuth().process();
2949+
}
2950+
2951+
29122952
function testFinishSignInWithCredential_upgradeAnonymous_noUser() {
29132953
testApp = new firebaseui.auth.testing.FakeAppClient(options);
29142954
testAuth = testApp.auth();

javascript/widgets/handler/common.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -486,15 +486,13 @@ firebaseui.auth.widget.handler.common.setLoggedIn =
486486
firebaseui.auth.storage.removeRememberAccount(app.getAppId());
487487
// After successful sign out from internal instance, sign in with credential
488488
// to the developer provided auth instance. Use the credential passed.
489-
var finishSignInPromise = app.finishSignInWithCredential(
489+
return app.finishSignInWithCredential(
490490
/** @type {!firebase.auth.AuthCredential} */ (credential))
491491
.then(function(user) {
492492
firebaseui.auth.widget.handler.common.setUserLoggedInExternal_(
493493
app, component, user, outputCred);
494494
// Catch error when signInSuccessUrl is required and not provided.
495495
}, onError).then(function() {}, onError);
496-
app.registerPending(finishSignInPromise);
497-
return finishSignInPromise;
498496
}, onError);
499497
app.registerPending(signOutAndSignInPromise);
500498
return goog.Promise.resolve(signOutAndSignInPromise);
@@ -1012,6 +1010,10 @@ firebaseui.auth.widget.handler.common.verifyPassword =
10121010
return;
10131011
}
10141012
switch (error['code']) {
1013+
case 'auth/email-already-in-use':
1014+
// Do nothing when anonymous user is getting updated.
1015+
// Developer should handle this in signInFailure callback.
1016+
break;
10151017
case 'auth/email-exists':
10161018
showInvalidEmail(error);
10171019
break;

javascript/widgets/handler/passwordsignin_test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ goog.require('goog.Promise');
2929
goog.require('goog.dom');
3030
goog.require('goog.dom.forms');
3131
goog.require('goog.testing.events');
32+
goog.require('goog.testing.recordFunction');
3233

3334

3435
function testHandlePasswordSignIn() {
@@ -65,6 +66,10 @@ function testHandlePasswordSignIn() {
6566

6667

6768
function testHandlePasswordSignIn_upgradeAnonymous_successfulSignIn() {
69+
testStubs.replace(
70+
firebaseui.auth.log,
71+
'error',
72+
goog.testing.recordFunction());
6873
var expectedCredential = firebase.auth.EmailAuthProvider.credential(
6974
passwordAccount.getEmail(), '123');
7075
// Expected FirebaseUI error.
@@ -98,6 +103,10 @@ function testHandlePasswordSignIn_upgradeAnonymous_successfulSignIn() {
98103
testAuth.assertSignOut([]);
99104
return testAuth.process();
100105
}).then(function() {
106+
mockClock.tick();
107+
// No error message should be displayed in console.
108+
/** @suppress {missingRequire} */
109+
assertEquals(0, firebaseui.auth.log.error.getCallCount());
101110
// No info bar should be displayed.
102111
assertNoInfoBarMessage();
103112
// UI should be disposed.

translations/ar-XB.xtb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@
3434
<translation id="1799407952500261728">‏‮Cook‬‏ ‏‮Islands‬‏</translation>
3535
<translation id="1870056762032541323">‏‮Wrong‬‏ ‏‮code‬‏. ‏‮Try‬‏ ‏‮again‬‏.</translation>
3636
<translation id="1898579907513173256">‏‮Macau‬‏</translation>
37-
<translation id="1929332760123475919"><ph name="P_START" />‏‮Hello‬‏ <ph name="DISPLAY_NAME" />,<ph name="P_END" /></translation>
38-
<translation id="1966996824429980990">‏‮Delete‬‏ ‏‮account‬‏</translation>
37+
<translation id="1933044638365301516">‏‮Sign‬‏ ‏‮in‬‏ ‏‮with‬‏ <ph name="STRING" /></translation>
3938
<translation id="1987722456379605552">‏‮Enter‬‏ ‏‮the‬‏ 6-‏‮digit‬‏ ‏‮code‬‏ ‏‮we‬‏ ‏‮sent‬‏ ‏‮to‬‏ <ph name="START_LINK" /><ph name="PHONE_NUMBER" /><ph name="END_LINK" /></translation>
4039
<translation id="2016421613709283485">‏‮Follow‬‏ ‏‮the‬‏ ‏‮instructions‬‏ ‏‮sent‬‏ ‏‮to‬‏ <ph name="PH_1" /> ‏‮to‬‏ ‏‮recover‬‏ ‏‮your‬‏ ‏‮password‬‏.</translation>
4140
<translation id="2035855087334775326">‏‮Hungary‬‏</translation>
@@ -294,6 +293,7 @@
294293
<translation id="6999773882165218263">‏‮First‬‏ &amp;amp; ‏‮last‬‏ ‏‮name‬‏</translation>
295294
<translation id="7012506961150923116">‏‮Grenada‬‏</translation>
296295
<translation id="7024571478138322659">‏‮Western‬‏ ‏‮Sahara‬‏</translation>
296+
<translation id="7062299334696934251">‏‮An‬‏ ‏‮unknown‬‏ ‏‮error‬‏ ‏‮occurred‬‏.</translation>
297297
<translation id="7064251114893721966">‏‮You‬‏’‏‮ve‬‏ ‏‮already‬‏ ‏‮used‬‏ <ph name="START_STRONG" /><ph name="EMAIL" /><ph name="END_STRONG" /> ‏‮to‬‏ ‏‮sign‬‏ ‏‮in‬‏. ‏‮Enter‬‏ ‏‮your‬‏ ‏‮password‬‏ ‏‮for‬‏ ‏‮that‬‏ ‏‮account‬‏.</translation>
298298
<translation id="7089485669419398254">‏‮Ireland‬‏</translation>
299299
<translation id="7093343209860483088">‏‮Democratic‬‏ ‏‮Republic‬‏ ‏‮Congo‬‏</translation>

translations/en-XA.xtb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@
3434
<translation id="1799407952500261728">[Çööķ Κļåñðš one two]</translation>
3535
<translation id="1870056762032541323">[Ŵŕöñĝ çöðé. Ţŕý åĝåîñ. one two three four five]</translation>
3636
<translation id="1898579907513173256">[Måçåû one]</translation>
37-
<translation id="1929332760123475919">[ᐅ<ph name="P_START" />ᐊĤéļļö ᐅ<ph name="DISPLAY_NAME" />ᐊ,ᐅ<ph name="P_END" />ᐊ one two three four]</translation>
38-
<translation id="1966996824429980990">[Ðéļéţé åççöûñţ one two]</translation>
37+
<translation id="1933044638365301516">[Šîĝñ îñ ŵîţĥ ᐅ<ph name="STRING" />ᐊ one two three four]</translation>
3938
<translation id="1987722456379605552">[Éñţéŕ ţĥé 6-ðîĝîţ çöðé ŵé šéñţ ţö ᐅ<ph name="START_LINK" />ᐊᐅ<ph name="PHONE_NUMBER" />ᐊᐅ<ph name="END_LINK" />ᐊ one two three four five six seven eight nine]</translation>
4039
<translation id="2016421613709283485">[Föļļöŵ ţĥé îñšţŕûçţîöñš šéñţ ţö ᐅ<ph name="PH_1" />ᐊ ţö ŕéçövéŕ ýöûŕ þåššŵöŕð. one two three four five six seven eight nine ten eleven twelve]</translation>
4140
<translation id="2035855087334775326">[Ĥûñĝåŕý one]</translation>
@@ -294,6 +293,7 @@
294293
<translation id="6999773882165218263">[Fîŕšţ &amp;amp; ļåšţ ñåmé one two three four]</translation>
295294
<translation id="7012506961150923116">[Ĝŕéñåðå one]</translation>
296295
<translation id="7024571478138322659">[Ŵéšţéŕñ Šåĥåŕå one two]</translation>
296+
<translation id="7062299334696934251">[Åñ ûñķñöŵñ éŕŕöŕ öççûŕŕéð. one two three four five six]</translation>
297297
<translation id="7064251114893721966">[Ýöû’vé åļŕéåðý ûšéð ᐅ<ph name="START_STRONG" />ᐊᐅ<ph name="EMAIL" />ᐊᐅ<ph name="END_STRONG" />ᐊ ţö šîĝñ îñ. Éñţéŕ ýöûŕ þåššŵöŕð ƒöŕ ţĥåţ åççöûñţ. one two three four five six seven eight nine ten eleven twelve thirteen fourteen]</translation>
298298
<translation id="7089485669419398254">[Îŕéļåñð one]</translation>
299299
<translation id="7093343209860483088">[Ðémöçŕåţîç Ŕéþûбļîç Çöñĝö one two three]</translation>

translations/iw.xtb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@
296296
<translation id="6999773882165218263">שם פרטי ומשפחה</translation>
297297
<translation id="7012506961150923116">גרנדה</translation>
298298
<translation id="7024571478138322659">סהרה המערבית</translation>
299+
<translation id="7062299334696934251">אירעה שגיאה לא ידועה.</translation>
299300
<translation id="7064251114893721966">כבר השתמשת בכתובת <ph name="START_STRONG" /><ph name="EMAIL" /><ph name="END_STRONG" /> כדי להיכנס. עליך להזין את הסיסמה לחשבון המשויך אליה.</translation>
300301
<translation id="7089485669419398254">אירלנד</translation>
301302
<translation id="7093343209860483088">הרפובליקה הדמוקרטית של קונגו</translation>

0 commit comments

Comments
 (0)