mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 21:43:21 +00:00
middleware: Make HostDomain into a process_request, not process_response.
It is more suited for `process_request`, since it should stop execution of the request if the domain is invalid. This code was likely added as a process_response (inea39fb2556) because there was already a process_response at the time (added7e786d5426, and no longer necessary sincedce6b4a40f). It quiets an unnecessary warning when logging in at a non-existent realm. This stops performing unnecessary work when we are going to throw it away and return a 404. The edge case to this is if the request _creates_ a realm, and is made using the URL of the new realm; this change would prevent the request before it occurs. While this does arise in tests, the tests do not reflect reality -- real requests to /accounts/register/ are made via POST to the same (default) realm, redirected there from `confirm-preregistrationuser`. The tests are adjusted to reflect real behavior. Tweaked by tabbott to add a block comment in HostDomainMiddleware.
This commit is contained in:
committed by
Tim Abbott
parent
816f91ae27
commit
f00ff1ef62
@@ -343,12 +343,7 @@ class OurAuthenticationForm(AuthenticationForm):
|
||||
|
||||
if username is not None and password:
|
||||
subdomain = get_subdomain(self.request)
|
||||
try:
|
||||
realm = get_realm(subdomain)
|
||||
except Realm.DoesNotExist:
|
||||
logging.warning("User %s attempted password login to nonexistent subdomain %s",
|
||||
username, subdomain)
|
||||
raise ValidationError("Realm does not exist")
|
||||
realm = get_realm(subdomain)
|
||||
|
||||
return_data: Dict[str, Any] = {}
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user