diff options
Diffstat (limited to 'models.py')
-rw-r--r-- | models.py | 21 |
1 files changed, 10 insertions, 11 deletions
@@ -16,20 +16,19 @@ class ChangePasswordForm(forms.Form): if new_password != new_password_again: raise forms.ValidationError('The typed passwords do not \ match.') - # Check that the length is at least 8 characters. - if not len(new_password) >= 8: + # Check that the length is at least 10 characters. + if not len(new_password) >= 10: raise forms.ValidationError('Your password needs to be at \ -least 8 characters long. Currently %d characters.' % len(new_password)) - # The password needs to contain at least one number, one upper - # and one lower case letter and one special character. - if not re.search('\d+', new_password): - raise forms.ValidationError('You need at least one number \ -in your password.') +least 10 characters long. Currently %d characters.' % len(new_password)) + # The password needs to contain at least one upper and one lower case + # letter and three numbers or special characters. if not re.search('[a-z]', new_password) or not re.search( '[A-Z]', new_password): raise forms.ValidationError('You need at least one upper \ case letter and one lower case letter in your password.') - if not re.search('[,.\[\]!@#$%^&*?_\(\)-]', new_password): - raise forms.ValidationError('You need at least one special \ -character i.e. ,.][!@#$%^&*?_()-') + numbers = re.findall('\d', new_password) + specials = re.findall('[,.\[\]!@#$%^&*?_\(\)-]', new_password) + if (len(numbers)+len(specials)) < 3: + raise forms.ValidationError('You need at least three numbers or \ +special characters i.e. 1234567890,.][!@#$%^&*?_()-') return cleaned_data
\ No newline at end of file |