realm_creation: Disable open realm creation if no password backend.

This commit is contained in:
Mateusz Mandera
2025-04-06 02:31:52 +08:00
committed by Tim Abbott
parent de37ab28a8
commit 57d77e0a55
2 changed files with 26 additions and 5 deletions

View File

@@ -891,11 +891,17 @@ def create_realm(request: HttpRequest, creation_key: str | None = None) -> HttpR
request,
"zerver/portico_error_pages/realm_creation_link_invalid.html",
)
if not settings.OPEN_REALM_CREATION and key_record is None:
return TemplateResponse(
request,
"zerver/portico_error_pages/realm_creation_disabled.html",
)
if key_record is None:
if not settings.OPEN_REALM_CREATION:
return TemplateResponse(
request,
"zerver/portico_error_pages/realm_creation_disabled.html",
)
if not password_auth_enabled():
return TemplateResponse(
request,
"zerver/portico_error_pages/realm_creation_disabled.html",
)
# When settings.OPEN_REALM_CREATION is enabled, anyone can create a new realm,
# with a few restrictions on their email address.