# Если сайт требует входа, не показывайте баннер «сайт перегружен», так как анонимный доступ отсутствует

**URL:** <https://meta.discourse.org/t/when-a-site-requires-login-do-not-show-site-is-overloaded-banner-there-is-no-anon-access/156688>\
**Category:** Feature\
**Created:** [03.Июль.2020 12:01:53 UTC](https://meta.discourse.org/t/when-a-site-requires-login-do-not-show-site-is-overloaded-banner-there-is-no-anon-access/156688 "2020-07-03T12:01:53Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![neounix](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neounix/32/215617_2.png) [@neounix](https://meta.discourse.org/u/neounix)\
**Post date:** [03.Июль.2020 12:50:56 UTC](https://meta.discourse.org/t/when-a-site-requires-login-do-not-show-site-is-overloaded-banner-there-is-no-anon-access/156688/2 "2020-07-03T12:50:56Z")

</div>

> [@meriksson](#):
>
> Так что интересно: какой порог для этого предупреждения и правильно ли он настроен?

Привет @meriksson

К сведению. Это уведомление срабатывает через cookie:

```plaintext
if ($.cookie("dosp") === "1") {
        $.removeCookie("dosp", { path: "/" });
        notices.push(
          Notice.create({
            text: I18n.t("forced_anonymous"),
            id: "forced-anonymous"
          })
        );
      }

```

Ссылка:

> <https://github.com/discourse/discourse/blob/ba00cc8ec457ce708cc1aec5d25afc38495cc52a/app/assets/javascripts/discourse/app/components/global-notice.js>

Поиск этого cookie на GitHub выдает:

> **[Build software better, together](https://github.com/search?q=repo%3Adiscourse%2Fdiscourse+dosp)**
>
> GitHub is where people build software. More than 150 million people use GitHub to discover, fork, and contribute to over 420 million projects.

Где force\_anon найден здесь:

```plaintext
 def initialize(app, settings = {})
      @app = app
    end

    def call(env)
      helper = Helper.new(env)
      force_anon = false
      if helper.should_force_anonymous?
        force_anon = env["DISCOURSE_FORCE_ANON"] = true
        helper.force_anonymous!
      end

```

Ссылка:

> **[Build software better, together](https://github.com/search?q=repo%3Adiscourse%2Fdiscourse+force_anon)**
>
> GitHub is where people build software. More than 150 million people use GitHub to discover, fork, and contribute to over 420 million projects.

Также см.:

> <https://github.com/discourse/discourse/blob/19814c5e8109dfb30b8a96e0762d062b200db392/lib/middleware/anonymous_cache.rb>

```plaintext
 MIN_TIME_TO_CHECK = 0.05
 ADP = "action_dispatch.request.parameters"

 def should_force_anonymous?
        if (queue_time = @env['REQUEST_QUEUE_SECONDS']) && get?
          if queue_time > GlobalSetting.force_anonymous_min_queue_seconds
            return check_logged_in_rate_limit!
          elsif queue_time >= MIN_TIME_TO_CHECK
            if !logged_in_anon_limiter.can_perform?
              return check_logged_in_rate_limit!
            end
          end
        end

   false
end

```

---

_[View the full topic](https://meta.discourse.org/t/when-a-site-requires-login-do-not-show-site-is-overloaded-banner-there-is-no-anon-access/156688)._
