_showAuthDialog()

in src/auth/auth-core.ts [680:748]


  _showAuthDialog({nonInteractive, error, canCancel, onTryAgain}: AuthDialogParams = {}) {
    const {embeddedLogin, onPostponeLogout, translations} = this.config;
    const cancelable = this.user?.guest || canCancel;
    const actualTranslations = translations ?? getTranslations();

    this._createInitDeferred();

    const closeDialog = () => {
      /* eslint-disable no-use-before-define */
      stopTokenListening?.();
      stopMessageListening?.();
      hide?.();
      /* eslint-enable no-use-before-define */
    };

    const onConfirm = () => {
      if (!embeddedLogin) {
        closeDialog();
        this.logout();
        return;
      }
      this._runEmbeddedLogin();
    };

    const onCancel = () => {
      this._embeddedFlow?.stop();
      this._storage?.sendMessage(Auth.CLOSE_WINDOW_MESSAGE, Date.now());
      closeDialog();
      if (!cancelable) {
        this._initDeferred?.resolve?.();
        this.listeners.trigger(LOGOUT_POSTPONED_EVENT);
        onPostponeLogout();
        return;
      }

      if (this.user?.guest && nonInteractive) {
        this.forceTokenUpdate();
      } else {
        this._initDeferred?.resolve?.();
      }
    };

    const onTryAgainClick = async () => {
      await onTryAgain?.();
      closeDialog();
    };

    const hide = this._authDialogService?.({
      ...this._service,
      loginCaption: actualTranslations.login,
      loginToCaption: actualTranslations.loginTo,
      confirmLabel: actualTranslations.login,
      tryAgainLabel: actualTranslations.tryAgainLabel,
      cancelLabel: cancelable ? actualTranslations.cancel : actualTranslations.postpone,
      errorMessage: this._extractErrorMessage(error, true),
      onConfirm,
      onCancel,
      onTryAgain: onTryAgain ? onTryAgainClick : undefined,
    });

    const stopTokenListening = this._storage?.onTokenChange(token => {
      if (token) {
        closeDialog();
        this._initDeferred?.resolve?.();
      }
    });

    const stopMessageListening = this._storage?.onMessage(Auth.CLOSE_WINDOW_MESSAGE, () => this._embeddedFlow?.stop());
  }