auth: Fix 500 error on accessing selfhosting subdomain user login page.

selfhosting in not to valid subdomain for user login, so we render
invalid_realm page on that URL.
This commit is contained in:
Aman Agrawal
2025-02-07 11:38:25 +05:30
committed by Tim Abbott
parent b6814d6192
commit a2dd84541d
3 changed files with 19 additions and 1 deletions

View File

@@ -889,9 +889,17 @@ def login_page(
next: str = "/",
**kwargs: Any,
) -> HttpResponse:
if get_subdomain(request) == settings.SOCIAL_AUTH_SUBDOMAIN:
subdomain = get_subdomain(request)
if subdomain == settings.SOCIAL_AUTH_SUBDOMAIN:
return social_auth_subdomain_login_page(request)
if subdomain == settings.SELF_HOSTING_MANAGEMENT_SUBDOMAIN:
context = {
"current_url": request.get_host(),
"is_selfhosting_management_error_page": True,
}
return render(request, "zerver/invalid_realm.html", status=404, context=context)
# To support previewing the Zulip login pages, we have a special option
# that disables the default behavior of redirecting logged-in users to the
# logged-in app.