Skip to content

Commit

Permalink
Merge pull request openedx#26477 from eduNEXT/MJG/Change_max_uername_len
Browse files Browse the repository at this point in the history
feat: Changed username max_length to the specified by django
  • Loading branch information
felipemontoya authored Mar 8, 2021
2 parents 1a0bfc2 + acc9eae commit 72fba56
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion common/djangoapps/third_party_auth/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
from openedx.core.djangoapps.theming.helpers import get_current_request
from openedx.core.djangoapps.user_api.accounts import USERNAME_MAX_LENGTH
from openedx.core.lib.hash_utils import create_hash256

from .lti import LTI_PARAMS_KEY, LTIAuthBackend
Expand Down Expand Up @@ -68,7 +69,7 @@ def clean_json(value, of_type):

def clean_username(username=''):
""" Simple helper method to ensure a username is compatible with our system requirements. """
return re.sub(r'[^-\w]+', '_', username)[:30]
return re.sub(r'[^-\w]+', '_', username)[:USERNAME_MAX_LENGTH]


class AuthNotConfigured(SocialAuthBaseException):
Expand Down
5 changes: 3 additions & 2 deletions openedx/core/djangoapps/user_api/accounts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Account constants
"""


from django.conf import settings
from django.utils.text import format_lazy
from django.utils.translation import ugettext_lazy as _

Expand All @@ -15,7 +15,8 @@

# The minimum and maximum length for the username account field
USERNAME_MIN_LENGTH = 2
USERNAME_MAX_LENGTH = 30
# Note: 30 chars is the default for historical reasons. Django uses 150 as the username length since 1.10
USERNAME_MAX_LENGTH = getattr(settings, 'USERNAME_MAX_LENGTH', 30)

# The minimum and maximum length for the email account field
EMAIL_MIN_LENGTH = 3
Expand Down

0 comments on commit 72fba56

Please sign in to comment.