zulip/zproject
Alex Vandiver 536bd3188e middleware: Move locale-setting before domain checking.
Calling `render()` in a middleware before LocaleMiddleware has run
will pick up the most-recently-set locale.  This may be from the
_previous_ request, since the current language is thread-local.  This
results in the "Organization does not exist" page occasionally being
in not-English, depending on the preferences of the request which that
thread just finished serving.

Move HostDomainMiddleware below LocaleMiddleware; none of the earlier
middlewares call `render()`, so are safe.  This will also allow the
"Organization does not exist" page to be localized based on the user's
browser preferences.

Unfortunately, it also means that the default LocaleMiddleware catches
the 404 from the HostDomainMiddlware and helpfully tries to check if
the failure is because the URL lacks a language component (e.g.
`/en/`) by turning it into a 304 to that new URL.  We must subclass
the default LocaleMiddleware to remove this unwanted functionality.

Doing so exposes a two places in tests that relied (directly or
indirectly) upon the redirection: '/confirmation_key'
was redirected to '/en/confirmation_key', since the non-i18n version
did not exist; and requests to `/stats/realm/not_existing_realm/`
incorrectly were expecting a 302, not a 404.

This regression likely came in during f00ff1ef62, since prior to
that, the HostDomainMiddleware ran _after_ the rest of the request had
completed.
2020-09-14 22:16:09 -07:00
..
jinja2 python: Prefer kwargs form of dict.update. 2020-09-03 17:51:09 -07:00
__init__.py
backends.py ldap: Fix inaccuracy in django_to_ldap_username comment. 2020-09-13 18:39:00 +02:00
computed_settings.py middleware: Move locale-setting before domain checking. 2020-09-14 22:16:09 -07:00
config.py python: Sort imports with isort. 2020-06-11 16:45:32 -07:00
configured_settings.py python: Sort imports with isort. 2020-06-11 16:45:32 -07:00
default_settings.py compose: Fix trailing slashes when creating Jitsi video meeting. 2020-08-26 12:01:11 -07:00
dev_settings.py dev_settings: Add EMAIL_PORT setting in zproject/dev_settings.py. 2020-08-04 11:03:40 -07:00
dev_urls.py middleware: Move locale-setting before domain checking. 2020-09-14 22:16:09 -07:00
email_backends.py dev_settings: Add EMAIL_PORT setting in zproject/dev_settings.py. 2020-08-04 11:03:40 -07:00
legacy_urls.py python: Sort imports with isort. 2020-06-11 16:45:32 -07:00
prod_settings_template.py compose: Fix trailing slashes when creating Jitsi video meeting. 2020-08-26 12:01:11 -07:00
sentry.py sentry: Add additional context (client, fallback realm) to Sentry tags. 2020-09-11 16:43:29 -07:00
settings.py python: Add noqa comments for the specific star imports we allow. 2020-06-11 15:36:43 -07:00
terms.md.template docs: Capitalize Markdown consistently. 2020-08-11 10:23:06 -07:00
test_extra_settings.py puppeteer: Rename CASPER_TESTS env variable to PUPPETEER_TESTS. 2020-09-09 13:38:39 -04:00
test_settings.py python: Sort imports with isort. 2020-06-11 16:45:32 -07:00
urls.py urls: Migrate re_path routes to path. 2020-09-12 14:29:26 -07:00
wsgi.py wsgi: Try to avoid extra django.setup calls. 2020-06-18 20:16:34 -07:00