firebaseui.auth.AuthUI.prototype.reset = function()

in javascript/widgets/authui.js [793:860]


firebaseui.auth.AuthUI.prototype.reset = function() {
  // Check if instance is already destroyed.
  this.checkIfDestroyed_();
  var self = this;
  // Remove the "lang" attribute that we set in start().
  if (this.widgetElement_) {
    this.widgetElement_.removeAttribute('lang');
  }
  // Unregister previous listener.
  if (this.widgetEventDispatcher_) {
    this.widgetEventDispatcher_.unregister();
  }
  this.revertLanguageCode();
  this.signInHint_ = null;
  // Clear email link sign-in state from URL if needed.
  this.clearEmailSignInState();
  // Removes pending status of previous redirect operations including redirect
  // back from federated sign in.
  firebaseui.auth.storage.removeRedirectStatus(this.getAppId());
  // Cancel One-Tap last operation.
  this.cancelOneTapSignIn();

  // After reset, if the sign-in widget callback is called again, it should not
  // resolve with the previous redirect result.
  this.getRedirectResult_ =
      /** @type {!goog.Promise<!firebase.auth.UserCredential>} */ (
      goog.Promise.resolve({
        'user': null,
        'credential': null
      }));
  // Reset widget AuthUI if it is the current instance.
  if (firebaseui.auth.AuthUI.widgetAuthUi_ == this) {
    firebaseui.auth.AuthUI.widgetAuthUi_ = null;
  }
  this.widgetElement_ = null;
  // Cancel all pending promises or run reset functions.
  for (var i = 0; i < this.pending_.length; i++) {
    if (typeof this.pending_[i] == 'function') {
      /** @type{function()} */ (this.pending_[i])();
    } else {
      // firebase.Promise may use the native Promise which does not have a
      // cancel method. Only goog.Promise offers that.
      if (this.pending_[i].cancel) {
        this.pending_[i].cancel();
      }
    }
  }
  // Clear all pending promises and reset functions.
  this.pending_ = [];
  // Remove pending email credential.
  firebaseui.auth.storage.removePendingEmailCredential(this.getAppId());
  // Dispose any remaining widget UI.
  if (this.currentComponent_) {
    this.currentComponent_.dispose();
    this.currentComponent_ = null;
  }
  // Reset current page id.
  this.currentPageId_ = null;
  // Signs Out internal Auth instance to avoid dangling Auth state.
  if (this.tempAuth_) {
    this.pendingInternalAuthSignOut_ = this.clearTempAuthState()
        .then(function() {
          self.pendingInternalAuthSignOut_ = null;
        }, function(error) {
          self.pendingInternalAuthSignOut_ = null;
        });
  }
};