Explorar o código

HUE-540. Special characters in username breaks useradmin app.

Harsh J %!s(int64=14) %!d(string=hai) anos
pai
achega
ec226cebda
Modificáronse 1 ficheiros con 3 adicións e 0 borrados
  1. 3 0
      apps/useradmin/src/useradmin/views.py

+ 3 - 0
apps/useradmin/src/useradmin/views.py

@@ -59,6 +59,9 @@ class UserChangeForm(django.contrib.auth.forms.UserChangeForm):
   This is similar, but not quite the same as djagno.contrib.auth.forms.UserChangeForm
   and UserCreationForm.
   """
+  username = forms.RegexField(label="Username", max_length=30, regex=r'^[\w]+$',
+          help_text = "Required. 30 characters or fewer. Letters and digits only.",
+          error_messages = {'invalid': "This value may contain only letters and numbers."})
   password1 = forms.CharField(label="Password", widget=forms.PasswordInput, required=False)
   password2 = forms.CharField(label="Password confirmation", widget=forms.PasswordInput, required=False)