Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 f00ff1e, since prior to that, the HostDomainMiddleware ran _after_ the rest of the request had completed.
- Loading branch information
Showing
5 changed files
with
27 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters