diff options
Diffstat (limited to 'django/contrib/auth/forms.py')
| -rw-r--r-- | django/contrib/auth/forms.py | 48 |
1 files changed, 35 insertions, 13 deletions
diff --git a/django/contrib/auth/forms.py b/django/contrib/auth/forms.py index cbce8ad6e2..d191635a9b 100644 --- a/django/contrib/auth/forms.py +++ b/django/contrib/auth/forms.py @@ -12,7 +12,9 @@ from django.utils.translation import ugettext, ugettext_lazy as _ from django.contrib.auth import authenticate, get_user_model from django.contrib.auth.models import User -from django.contrib.auth.hashers import UNUSABLE_PASSWORD, identify_hasher +from django.contrib.auth.hashers import ( + MAXIMUM_PASSWORD_LENGTH, UNUSABLE_PASSWORD, identify_hasher, +) from django.contrib.auth.tokens import default_token_generator from django.contrib.sites.models import get_current_site @@ -75,9 +77,10 @@ class UserCreationForm(forms.ModelForm): 'invalid': _("This value may contain only letters, numbers and " "@/./+/-/_ characters.")}) password1 = forms.CharField(label=_("Password"), - widget=forms.PasswordInput) + widget=forms.PasswordInput, max_length=MAXIMUM_PASSWORD_LENGTH) password2 = forms.CharField(label=_("Password confirmation"), widget=forms.PasswordInput, + max_length=MAXIMUM_PASSWORD_LENGTH, help_text=_("Enter the same password as above, for verification.")) class Meta: @@ -145,7 +148,11 @@ class AuthenticationForm(forms.Form): username/password logins. """ username = forms.CharField(max_length=254) - password = forms.CharField(label=_("Password"), widget=forms.PasswordInput) + password = forms.CharField( + label=_("Password"), + widget=forms.PasswordInput, + max_length=MAXIMUM_PASSWORD_LENGTH, + ) error_messages = { 'invalid_login': _("Please enter a correct %(username)s and password. " @@ -269,10 +276,16 @@ class SetPasswordForm(forms.Form): error_messages = { 'password_mismatch': _("The two password fields didn't match."), } - new_password1 = forms.CharField(label=_("New password"), - widget=forms.PasswordInput) - new_password2 = forms.CharField(label=_("New password confirmation"), - widget=forms.PasswordInput) + new_password1 = forms.CharField( + label=_("New password"), + widget=forms.PasswordInput, + max_length=MAXIMUM_PASSWORD_LENGTH, + ) + new_password2 = forms.CharField( + label=_("New password confirmation"), + widget=forms.PasswordInput, + max_length=MAXIMUM_PASSWORD_LENGTH, + ) def __init__(self, user, *args, **kwargs): self.user = user @@ -303,8 +316,11 @@ class PasswordChangeForm(SetPasswordForm): 'password_incorrect': _("Your old password was entered incorrectly. " "Please enter it again."), }) - old_password = forms.CharField(label=_("Old password"), - widget=forms.PasswordInput) + old_password = forms.CharField( + label=_("Old password"), + widget=forms.PasswordInput, + max_length=MAXIMUM_PASSWORD_LENGTH, + ) def clean_old_password(self): """ @@ -329,10 +345,16 @@ class AdminPasswordChangeForm(forms.Form): error_messages = { 'password_mismatch': _("The two password fields didn't match."), } - password1 = forms.CharField(label=_("Password"), - widget=forms.PasswordInput) - password2 = forms.CharField(label=_("Password (again)"), - widget=forms.PasswordInput) + password1 = forms.CharField( + label=_("Password"), + widget=forms.PasswordInput, + max_length=MAXIMUM_PASSWORD_LENGTH, + ) + password2 = forms.CharField( + label=_("Password (again)"), + widget=forms.PasswordInput, + max_length=MAXIMUM_PASSWORD_LENGTH, + ) def __init__(self, user, *args, **kwargs): self.user = user |
