Skip to content

Commit 2a56caa

Browse files
authored
fix: made username readonly (#568)
1 parent 437c1db commit 2a56caa

3 files changed

Lines changed: 4 additions & 3 deletions

File tree

openedx/core/djangoapps/user_api/accounts/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
# It is shown to users who attempt to create a new account using invalid characters
4141
# in the username.
4242
USERNAME_INVALID_CHARS_ASCII = _(
43-
"Usernames can only contain letters (A-Z, a-z), numerals (0-9), underscores (_), and hyphens (-)."
43+
"Usernames must not contain the following symbols: #, <, >, [, ], |, {, }, /, \, :, @"
4444
)
4545

4646
# Translators: This message is shown only when the Unicode usernames are allowed.

openedx/core/djangoapps/user_api/helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class FormDescription:
9898
ALLOWED_TYPES = ["text", "email", "select", "textarea", "checkbox", "plaintext", "password", "hidden"]
9999

100100
ALLOWED_RESTRICTIONS = {
101-
"text": ["min_length", "max_length"],
101+
"text": ["min_length", "max_length", "readonly"],
102102
"password": ["min_length", "max_length", "min_upper", "min_lower",
103103
"min_punctuation", "min_symbol", "min_numeric", "min_alphabetic"],
104104
"email": ["min_length", "max_length", "readonly"],

openedx/core/djangoapps/user_authn/views/registration_form.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
3030
from openedx.core.djangoapps.user_api import accounts
3131
from openedx.core.djangoapps.user_api.helpers import FormDescription
32+
from openedx.core.djangoapps.user_authn.toggles import is_require_third_party_auth_enabled
3233
from openedx.core.djangoapps.user_authn.utils import check_pwned_password
3334
from openedx.core.djangoapps.user_authn.utils import is_registration_api_v1 as is_api_v1
3435
from openedx.core.djangoapps.user_authn.views.utils import remove_disabled_country_from_list
@@ -590,7 +591,7 @@ def _add_username_field(self, form_desc, required=True):
590591
"username",
591592
label=username_label,
592593
instructions=username_instructions,
593-
restrictions={
594+
restrictions={"readonly": "readonly"} if is_require_third_party_auth_enabled() else {
594595
"min_length": accounts.USERNAME_MIN_LENGTH,
595596
"max_length": accounts.USERNAME_MAX_LENGTH,
596597
},

0 commit comments

Comments
 (0)