Browse Source

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

Harsh J 14 năm trước cách đây
mục cha
commit
ec226cebda
1 tập tin đã thay đổi với 3 bổ sung0 xóa
  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)