@@ -1086,7 +1086,7 @@ firebaseui.auth.AuthUI.prototype.upgradeWithEmailLink = function(
10861086 p = this . getAuth ( ) . signInWithEmailLink ( email , link )
10871087 . then ( function ( userCredential ) {
10881088 return userCredential [ 'user' ]
1089- . linkAndRetrieveDataWithCredential ( pendingCredential ) ;
1089+ . linkWithCredential ( pendingCredential ) ;
10901090 } )
10911091 . then ( function ( linkedUserCredential ) {
10921092 return self . clearTempAuthState ( ) ;
@@ -1103,7 +1103,7 @@ firebaseui.auth.AuthUI.prototype.upgradeWithEmailLink = function(
11031103 if ( ! signInMethods . length ) {
11041104 // New email. Linking email credential to anonymous user should
11051105 // succeed.
1106- return user . linkAndRetrieveDataWithCredential ( credential ) ;
1106+ return user . linkWithCredential ( credential ) ;
11071107 } else {
11081108 // Existing email will trigger merge conflict. In this case, we
11091109 // avoid consuming the one-time credential.
@@ -1150,7 +1150,7 @@ firebaseui.auth.AuthUI.prototype.signInWithEmailLink = function(
11501150 // If there is a pending credential, link it to signed in user.
11511151 if ( pendingCredential ) {
11521152 return userCredential [ 'user' ]
1153- . linkAndRetrieveDataWithCredential ( pendingCredential )
1153+ . linkWithCredential ( pendingCredential )
11541154 . then ( function ( linkedUserCredential ) {
11551155 authResult = {
11561156 'user' : linkedUserCredential [ 'user' ] ,
@@ -1278,7 +1278,7 @@ firebaseui.auth.AuthUI.prototype.startCreateUserWithEmailAndPassword =
12781278 // Auth user. Otherwise merge conflict will always occur when linking the
12791279 // credential to the external anonymous user after creation.
12801280 return /** @type {!firebase.Promise<!firebase.auth.UserCredential> } */ (
1281- user . linkAndRetrieveDataWithCredential ( credential ) ) ;
1281+ user . linkWithCredential ( credential ) ) ;
12821282 } else {
12831283 // Start create user with email and password. This runs on the internal
12841284 // Auth instance as finish sign in will sign in with that same credential
@@ -1310,7 +1310,7 @@ firebaseui.auth.AuthUI.prototype.startSignInWithCredential =
13101310 // Auth user. Otherwise merge conflict will always occur when linking the
13111311 // credential to the external anonymous user after creation.
13121312 return /** @type {!firebase.Promise<!firebase.auth.UserCredential> } */ (
1313- user . linkAndRetrieveDataWithCredential ( credential )
1313+ user . linkWithCredential ( credential )
13141314 . then ( function ( result ) {
13151315 return result ;
13161316 } , function ( error ) {
@@ -1332,7 +1332,7 @@ firebaseui.auth.AuthUI.prototype.startSignInWithCredential =
13321332 // Starts sign in with a Firebase Auth credential, typically an OAuth
13331333 // credential. This runs on the internal Auth instance as finish sign in
13341334 // will sign in with that same credential to developer Auth instance.
1335- return self . getAuth ( ) . signInAndRetrieveDataWithCredential ( credential ) ;
1335+ return self . getAuth ( ) . signInWithCredential ( credential ) ;
13361336 }
13371337 } ;
13381338 // Initialize current user if auto upgrade is enabled beforing running
@@ -1501,89 +1501,6 @@ firebaseui.auth.AuthUI.prototype.startSignInAnonymously = function() {
15011501} ;
15021502
15031503
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-
15871504/**
15881505 * Finishes FirebaseUI login with the given 3rd party credentials.
15891506 * @param {!firebaseui.auth.AuthResult } authResult The Auth result.
@@ -1613,7 +1530,7 @@ firebaseui.auth.AuthUI.prototype.finishSignInAndRetrieveDataWithAuthResult =
16131530 // mismatch occurs and the user continues with the new account.
16141531 return /** @type {!firebase.Promise<!firebaseui.auth.AuthResult> } */ (
16151532 self . clearTempAuthState ( ) . then ( function ( ) {
1616- return user . linkAndRetrieveDataWithCredential (
1533+ return user . linkWithCredential (
16171534 authResult [ 'credential' ] ) ;
16181535 } ) . then ( function ( userCredential ) {
16191536 authResult [ 'user' ] = userCredential [ 'user' ] ;
0 commit comments