cb = function(user) {
    if (user) {
      // For anonymous user upgrade, call link with phone number on the external
      // user.
      return user.linkWithPhoneNumber(phoneNumber, appVerifier)
          .then(function(confirmationResult) {
            return new firebaseui.auth.PhoneAuthResult(confirmationResult,
                function(error) {
                  if (error.code == 'auth/credential-already-in-use') {
                    return self.onUpgradeError(error);
                  }
                  throw error;
                });
          });
    } else {
      // Starts sign in with phone number. This runs on the external Auth
      // instance.
      return self.getExternalAuth().signInWithPhoneNumber(
          phoneNumber, appVerifier).then(function(confirmationResult) {
            return new firebaseui.auth.PhoneAuthResult(confirmationResult);
          });
    }
  }
Signs in with a phone number using the app verifier instance and returns a
promise that resolves with the confirmation result which on confirmation
will resolve with the UserCredential object.
@param {string} phoneNumber The phone number to authenticate with.
@param {!firebase.auth.ApplicationVerifier} appVerifier The application
    verifier.
@return {!firebase.Promise<!firebaseui.auth.PhoneAuthResult>}