create_user: Specify tos_version=None explicitly in automation.

This is an important design detail, so we document this aspect of
creating users via both the management command and API code paths with
an explicit parameter value and comment.
This commit is contained in:
Tim Abbott
2022-03-20 20:43:43 -07:00
committed by Tim Abbott
parent 4f3894f9f1
commit fddd83394e
2 changed files with 17 additions and 1 deletions

View File

@@ -74,6 +74,11 @@ parameters, or specify no parameters for interactive user creation."""
pw,
realm,
full_name,
# Explicitly set tos_version=None. For servers that
# have configured Terms of Service, this means that
# users created via this mechanism will be prompted to
# accept the Terms of Service on first login.
tos_version=None,
acting_user=None,
)
except IntegrityError:

View File

@@ -641,7 +641,18 @@ def create_user_backend(
if not check_password_strength(password):
raise JsonableError(PASSWORD_TOO_WEAK_ERROR)
target_user = do_create_user(email, password, realm, full_name, acting_user=user_profile)
target_user = do_create_user(
email,
password,
realm,
full_name,
# Explicitly set tos_version=None. For servers that have
# configured Terms of Service, this means that users created
# via this mechanism will be prompted to accept the Terms of
# Service on first login.
tos_version=None,
acting_user=user_profile,
)
return json_success(request, data={"user_id": target_user.id})