demo-orgs: Make password not required for demo org creation.

Creating a demo organization will not require the user to
set either an email or password, so explicitly set the
password field to not be required for that case.

Updates the form submitted in the dev environment to create
a new demo organization to not send a password value.
This commit is contained in:
Lauryn Menard 2025-06-18 17:19:03 +02:00 committed by Tim Abbott
parent b4da918c00
commit 425abd83fc
2 changed files with 8 additions and 3 deletions

View File

@ -118,7 +118,6 @@ def register_demo_development_realm(request: HttpRequest) -> HttpResponse:
realm_default_language=realm_default_language,
email_address_visibility=email_address_visibility,
full_name=name,
password="test",
realm_subdomain=realm_subdomain,
terms="true",
is_demo_organization="true",

View File

@ -614,7 +614,12 @@ def registration_helper(
pass
form = RegistrationForm(postdata, realm_creation=realm_creation, realm=realm)
if not (password_auth_enabled(realm) and password_required):
if realm_creation and demo_organization_creation:
# TODO: Remove settings.DEVELOPMENT when demo organization feature ready
# to be fully implemented.
assert settings.DEVELOPMENT
form["password"].field.required = False
elif not (password_auth_enabled(realm) and password_required):
form["password"].field.required = False
if form.is_valid():
@ -623,7 +628,8 @@ def registration_helper(
else:
# If the user wasn't prompted for a password when
# completing the authentication form (because they're
# signing up with SSO and no password is required), set
# signing up with SSO and no password is required, or
# because they're creating a new demo organization), set
# the password field to `None` (Which causes Django to
# create an unusable password).
password = None