diff options
| author | Bobby <[email protected]> | 2023-01-08 13:01:35 -0500 |
|---|---|---|
| committer | Bobby <[email protected]> | 2023-01-08 13:01:35 -0500 |
| commit | 1a45d7ccb31d641c3d175aab862866f8b9a2f8cd (patch) | |
| tree | d6749b028f7d04e51b9dab54811c7898e34e0e91 /users/forms.py | |
| parent | 8d270d0da154d8a863401581e742de7a0eb191ed (diff) | |
| download | thatcomputerscientist-1a45d7ccb31d641c3d175aab862866f8b9a2f8cd.tar.xz thatcomputerscientist-1a45d7ccb31d641c3d175aab862866f8b9a2f8cd.zip | |
Password length validation
Diffstat (limited to 'users/forms.py')
| -rw-r--r-- | users/forms.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/users/forms.py b/users/forms.py index 8b02fef5..43b9230a 100644 --- a/users/forms.py +++ b/users/forms.py @@ -14,8 +14,8 @@ from .tokens import account_activation_token class RegisterForm(forms.Form): username = forms.CharField(label='Username', max_length=30, min_length=4) email = forms.EmailField(label='Email') - 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, min_length=8) + password2 = forms.CharField(label='Password (again)', widget=forms.PasswordInput, min_length=8) captcha = forms.CharField(label='Captcha', max_length=6) expected_captcha = None @@ -32,6 +32,8 @@ class RegisterForm(forms.Form): if password1 and password2: if password1 != password2: raise forms.ValidationError('Passwords do not match.') + if len(password1) < 8: + raise forms.ValidationError('Password must be at least 8 characters long.') if str.lower(captcha) != str.lower(self.expected_captcha): raise forms.ValidationError('Captcha does not match.') if User.objects.filter(username=cleaned_data.get('username')).exists(): |
