cb = function(user) {
          if (user) {
            // signOut the user.
            return self.clearTempAuthState().then(function() {
              // Eligible anonymous user upgrade.
              // On anonymous user upgrade with existing email/password, merge
              // conflict will always occur, trigger signInFailure as soon as
              // password is confirmed.
              return self.onUpgradeError(
                  {'code': 'auth/email-already-in-use'},
                  firebase.auth.EmailAuthProvider.credential(email, password));
            });
          } else {
            return result;
          }
        }
@type {!firebase.Promise<!firebase.auth.UserCredential>}