Commit f76fe7b7 authored by Noe Nieto's avatar Noe Nieto 💬

Fix bad words validation ;Purism/LibremOne/task#35

parent 9b120d57
......@@ -23,8 +23,10 @@ User = get_user_model()
def validate_reserved_names(value):
if value in settings.REG_BAD_SUBSTRINGS:
raise ValidationError(validators.RESERVED_NAME, code='invalid')
# premature optimization is the root of all evil
for bad_word in settings.REG_BAD_SUBSTRINGS:
if bad_word in value:
raise ValidationError(validators.RESERVED_NAME, code='invalid')
class CartRegistrationForm(RegistrationForm):
......
......@@ -23,7 +23,7 @@ REG_PERSON_BASE_DN=ou=people,dc=example,dc=com
REG_PERSON_OBJECT_CLASSES=inetOrgPerson,organizationalPerson,person
REG_GROUP_BASE_DN=ou=groups,dc=example,dc=com
REG_GROUP_OBJECT_CLASSES=groupOfNames
REG_BAD_SUBSTRINGS=foo,bar,baz,solovino
REG_BAD_SUBSTRINGS=peanut,butter,jelly,time
AUTH_LDAP_SERVER_URI=ldap://ldap.example.com
AUTH_LDAP_START_TLS=True
AUTH_LDAP_BIND_DN=cn=admin,dc=example,dc=com
......
......@@ -87,7 +87,7 @@ REG_PERSON_OBJECT_CLASSES = config("REG_PERSON_OBJECT_CLASSES", cast=Csv())
REG_GROUP_BASE_DN = config("REG_GROUP_BASE_DN")
REG_GROUP_OBJECT_CLASSES = config("REG_GROUP_OBJECT_CLASSES", cast=Csv())
REG_BAD_SUBSTRINGS = config.get("REG_BAD_SUBSTRINGS", "")
REG_BAD_SUBSTRINGS = config.get("REG_BAD_SUBSTRINGS", cast=Csv(str))
#
# AUTHENTICATION
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment