Ticket #5786: django-auth-username-characters.patch

File django-auth-username-characters.patch, 1.8 KB (added by alextreme, 15 years ago)

Allows common punctuation characters in username

  • django/contrib/auth/forms.py

    diff -Naur ../Django-1.1-orig/django/contrib/auth/forms.py ./django/contrib/auth/forms.py
    old new  
    1111    """
    1212    A form that creates a user, with no privileges, from the given username and password.
    1313    """
    14     username = forms.RegexField(label=_("Username"), max_length=30, regex=r'^\w+$',
    15         help_text = _("Required. 30 characters or fewer. Alphanumeric characters only (letters, digits and underscores)."),
    16         error_message = _("This value must contain only letters, numbers and underscores."))
     14    username = forms.RegexField(label=_("Username"), max_length=30, regex=r'^[\w.@+-]+$',
     15        help_text = _("Required. 30 characters or fewer. Letters, digits and @/./+/-/_ only."),
     16        error_message = _("This value may contain only letters, numbers and @/./+/-/_ characters."))
    1717    password1 = forms.CharField(label=_("Password"), widget=forms.PasswordInput)
    1818    password2 = forms.CharField(label=_("Password confirmation"), widget=forms.PasswordInput)
    1919
     
    4444        return user
    4545
    4646class UserChangeForm(forms.ModelForm):
    47     username = forms.RegexField(label=_("Username"), max_length=30, regex=r'^\w+$',
    48         help_text = _("Required. 30 characters or fewer. Alphanumeric characters only (letters, digits and underscores)."),
    49         error_message = _("This value must contain only letters, numbers and underscores."))
     47    username = forms.RegexField(label=_("Username"), max_length=30, regex=r'^[\w.@+-]+$',
     48        help_text = _("Required. 30 characters or fewer. Letters, digits and @/./+/-/_ only."),
     49        error_message = _("This value may contain only letters, numbers and @/./+/-/_ characters."))
    5050   
    5151    class Meta:
    5252        model = User
Back to Top