additional custom password validator
This commit is contained in:
@@ -1805,7 +1805,7 @@ def add_workout_indoorrace(ws,race,r,recordid=0,doregister=False):
|
|||||||
else:
|
else:
|
||||||
record.distance = ws[0].distance
|
record.distance = ws[0].distance
|
||||||
record.duration = ws[0].duration
|
record.duration = ws[0].duration
|
||||||
else:
|
else: # pragma: no cover
|
||||||
t = ws[0].duration
|
t = ws[0].duration
|
||||||
seconds = t.second+t.minute*60.+t.hour*3600.+t.microsecond/1.e6
|
seconds = t.second+t.minute*60.+t.hour*3600.+t.microsecond/1.e6
|
||||||
if seconds != race.sessionvalue*60.: # pragma: no cover
|
if seconds != race.sessionvalue*60.: # pragma: no cover
|
||||||
|
|||||||
BIN
rowers/tests/testdata/testdata.tcx.gz
vendored
Normal file
BIN
rowers/tests/testdata/testdata.tcx.gz
vendored
Normal file
Binary file not shown.
23
rowers/validator.py
Normal file
23
rowers/validator.py
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
from django.core.exceptions import ValidationError
|
||||||
|
from django.utils.translation import gettext as _
|
||||||
|
|
||||||
|
class LettersAndDigitsValidator:
|
||||||
|
|
||||||
|
def validate(self, password, user=None):
|
||||||
|
vals = {
|
||||||
|
'Password must contain an uppercase letter.': lambda s: any(x.isupper() for x in s),
|
||||||
|
'Password must contain a lowercase letter.': lambda s: any(x.islower() for x in s),
|
||||||
|
'Password must contain a digit.': lambda s: any(x.isdigit() for x in s),
|
||||||
|
'Password cannot contain white spaces.': lambda s: not any(x.isspace() for x in s)
|
||||||
|
}
|
||||||
|
valid = None
|
||||||
|
for n, val in vals.items():
|
||||||
|
if not val(password):
|
||||||
|
valid = False
|
||||||
|
raise ValidationError(n)
|
||||||
|
return valid
|
||||||
|
|
||||||
|
def get_help_text(self):
|
||||||
|
return _(
|
||||||
|
"Your password must contain an uppercase letter, a lowercase letter, and a digit"
|
||||||
|
)
|
||||||
@@ -197,6 +197,9 @@ AUTH_PASSWORD_VALIDATORS = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
|
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
|
||||||
|
'OPTIONS': {
|
||||||
|
'min_length': 9,
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
|
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
|
||||||
@@ -204,6 +207,9 @@ AUTH_PASSWORD_VALIDATORS = [
|
|||||||
{
|
{
|
||||||
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
|
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
'NAME': 'rowers.validator.LettersAndDigitsValidator',
|
||||||
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user