@@ -1086,7 +1086,7 @@ firebaseui.auth.AuthUI.prototype.upgradeWithEmailLink = function(
1086
1086
p = this . getAuth ( ) . signInWithEmailLink ( email , link )
1087
1087
. then ( function ( userCredential ) {
1088
1088
return userCredential [ 'user' ]
1089
- . linkAndRetrieveDataWithCredential ( pendingCredential ) ;
1089
+ . linkWithCredential ( pendingCredential ) ;
1090
1090
} )
1091
1091
. then ( function ( linkedUserCredential ) {
1092
1092
return self . clearTempAuthState ( ) ;
@@ -1103,7 +1103,7 @@ firebaseui.auth.AuthUI.prototype.upgradeWithEmailLink = function(
1103
1103
if ( ! signInMethods . length ) {
1104
1104
// New email. Linking email credential to anonymous user should
1105
1105
// succeed.
1106
- return user . linkAndRetrieveDataWithCredential ( credential ) ;
1106
+ return user . linkWithCredential ( credential ) ;
1107
1107
} else {
1108
1108
// Existing email will trigger merge conflict. In this case, we
1109
1109
// avoid consuming the one-time credential.
@@ -1150,7 +1150,7 @@ firebaseui.auth.AuthUI.prototype.signInWithEmailLink = function(
1150
1150
// If there is a pending credential, link it to signed in user.
1151
1151
if ( pendingCredential ) {
1152
1152
return userCredential [ 'user' ]
1153
- . linkAndRetrieveDataWithCredential ( pendingCredential )
1153
+ . linkWithCredential ( pendingCredential )
1154
1154
. then ( function ( linkedUserCredential ) {
1155
1155
authResult = {
1156
1156
'user' : linkedUserCredential [ 'user' ] ,
@@ -1278,7 +1278,7 @@ firebaseui.auth.AuthUI.prototype.startCreateUserWithEmailAndPassword =
1278
1278
// Auth user. Otherwise merge conflict will always occur when linking the
1279
1279
// credential to the external anonymous user after creation.
1280
1280
return /** @type {!firebase.Promise<!firebase.auth.UserCredential> } */ (
1281
- user . linkAndRetrieveDataWithCredential ( credential ) ) ;
1281
+ user . linkWithCredential ( credential ) ) ;
1282
1282
} else {
1283
1283
// Start create user with email and password. This runs on the internal
1284
1284
// Auth instance as finish sign in will sign in with that same credential
@@ -1310,7 +1310,7 @@ firebaseui.auth.AuthUI.prototype.startSignInWithCredential =
1310
1310
// Auth user. Otherwise merge conflict will always occur when linking the
1311
1311
// credential to the external anonymous user after creation.
1312
1312
return /** @type {!firebase.Promise<!firebase.auth.UserCredential> } */ (
1313
- user . linkAndRetrieveDataWithCredential ( credential )
1313
+ user . linkWithCredential ( credential )
1314
1314
. then ( function ( result ) {
1315
1315
return result ;
1316
1316
} , function ( error ) {
@@ -1332,7 +1332,7 @@ firebaseui.auth.AuthUI.prototype.startSignInWithCredential =
1332
1332
// Starts sign in with a Firebase Auth credential, typically an OAuth
1333
1333
// credential. This runs on the internal Auth instance as finish sign in
1334
1334
// will sign in with that same credential to developer Auth instance.
1335
- return self . getAuth ( ) . signInAndRetrieveDataWithCredential ( credential ) ;
1335
+ return self . getAuth ( ) . signInWithCredential ( credential ) ;
1336
1336
}
1337
1337
} ;
1338
1338
// Initialize current user if auto upgrade is enabled beforing running
@@ -1501,89 +1501,6 @@ firebaseui.auth.AuthUI.prototype.startSignInAnonymously = function() {
1501
1501
} ;
1502
1502
1503
1503
1504
- /**
1505
- * Finishes FirebaseUI login with the given 3rd party credentials.
1506
- * @param {!firebase.auth.AuthCredential } credential The auth credential.
1507
- * @param {?firebase.User= } opt_user The optional user to sign in with if
1508
- * available.
1509
- * @return {!firebase.Promise<!firebase.User> }
1510
- */
1511
- firebaseui . auth . AuthUI . prototype . finishSignInWithCredential =
1512
- function ( credential , opt_user ) {
1513
- // Check if instance is already destroyed.
1514
- this . checkIfDestroyed_ ( ) ;
1515
- var self = this ;
1516
- var cb = function ( user ) {
1517
- // Anonymous user upgrade successful, sign out on internal instance and
1518
- // resolve with the user. No need to sign in again with the same credential
1519
- // on the external Auth instance.
1520
- // If user is signed in on internal instance, ignore the user on external
1521
- // instance, sign out on internal instance and finish the sign in on
1522
- // external instance.
1523
- if ( self . currentUser_ &&
1524
- ! self . currentUser_ [ 'isAnonymous' ] &&
1525
- self . getConfig ( ) . autoUpgradeAnonymousUsers ( ) &&
1526
- ! self . getAuth ( ) . currentUser ) {
1527
- return self . clearTempAuthState ( ) . then ( function ( ) {
1528
- return self . currentUser_ ;
1529
- } ) ;
1530
- } else if ( user ) {
1531
- // TODO: optimize and fail directly as this will fail in most cases
1532
- // with error credential already in use.
1533
- // There are cases where this is required. For example, when email
1534
- // mismatch occurs and the user continues with the new account.
1535
- return /** @type {!firebase.Promise<!firebase.User> } */ (
1536
- self . clearTempAuthState ( ) . then ( function ( ) {
1537
- return user . linkWithCredential ( credential ) ;
1538
- } ) . then ( function ( ) {
1539
- return user ;
1540
- } , function ( error ) {
1541
- // Rethrow email already in use error so it can trigger the account
1542
- // linking flow.
1543
- if ( error &&
1544
- error [ 'code' ] == 'auth/email-already-in-use' &&
1545
- error [ 'email' ] && error [ 'credential' ] ) {
1546
- throw error ;
1547
- }
1548
- // For all other errors, run onUpgrade check.
1549
- return self . onUpgradeError ( error , credential ) ;
1550
- } ) ) ;
1551
- } else {
1552
- // Finishes sign in with the supplied credential on the developer provided
1553
- // Auth instance. On completion, this will redirect to signInSuccessUrl or
1554
- // trigger the signInSuccess callback.
1555
- return self . clearTempAuthState ( ) . then ( function ( ) {
1556
- // updateCurrentUser is more efficient and less error prone than
1557
- // signInWithCredential.
1558
- // The former can resolve the operation without any network request
1559
- // whereas the latter will send 2 requests.
1560
- // In addition, updateCurrentUser has lower risk of failure in the
1561
- // following cases:
1562
- // 1. No network connection: operation can execute without any network
1563
- // call in most cases.
1564
- // 2. Will not run into expired OAuth credential errors unlike
1565
- // signInWithCredential. This may happen if the user waits too long
1566
- // before completing sign-in in the email mismatch flow.
1567
- // 3. Ability to copy a user for all providers. Some OAuth providers
1568
- // cannot be used headlessly or their credentials are one-time only.
1569
- if ( ! ! opt_user ) {
1570
- return self . getExternalAuth ( ) . updateCurrentUser ( opt_user )
1571
- . then ( function ( ) {
1572
- // Return currentUser on external instance.
1573
- return self . getExternalAuth ( ) . currentUser ;
1574
- } ) ;
1575
- }
1576
- // If no user is available fallback to signInWithCredential.
1577
- return self . getExternalAuth ( ) . signInWithCredential ( credential ) ;
1578
- } ) ;
1579
- }
1580
- } ;
1581
- // Initialize current user if auto upgrade is enabled beforing running
1582
- // callback and returning result.
1583
- return this . initializeForAutoUpgrade_ ( cb ) ;
1584
- } ;
1585
-
1586
-
1587
1504
/**
1588
1505
* Finishes FirebaseUI login with the given 3rd party credentials.
1589
1506
* @param {!firebaseui.auth.AuthResult } authResult The Auth result.
@@ -1613,7 +1530,7 @@ firebaseui.auth.AuthUI.prototype.finishSignInAndRetrieveDataWithAuthResult =
1613
1530
// mismatch occurs and the user continues with the new account.
1614
1531
return /** @type {!firebase.Promise<!firebaseui.auth.AuthResult> } */ (
1615
1532
self . clearTempAuthState ( ) . then ( function ( ) {
1616
- return user . linkAndRetrieveDataWithCredential (
1533
+ return user . linkWithCredential (
1617
1534
authResult [ 'credential' ] ) ;
1618
1535
} ) . then ( function ( userCredential ) {
1619
1536
authResult [ 'user' ] = userCredential [ 'user' ] ;
0 commit comments