diff --git a/app.py b/app.py index b7294de..0dec70e 100644 --- a/app.py +++ b/app.py @@ -27,7 +27,7 @@ from ldap3 import Server, Connection, ALL from ldap3 import SIMPLE, SUBTREE, MODIFY_REPLACE, ALL_ATTRIBUTES from ldap3.core.exceptions import LDAPBindError, LDAPConstraintViolationResult, \ LDAPInvalidCredentialsResult, LDAPUserNameIsMandatoryError, \ - LDAPSocketOpenError, LDAPExceptionError + LDAPSocketOpenError, LDAPExceptionError, LDAPAttributeOrValueExistsResult import logging from os import getenv, environ, path from libs import flist, slist @@ -148,7 +148,7 @@ def post_signup(): result = random.choice(flist.firstname) elif arg == 'surname': result = random.choice(slist.surname) - return(result.lower()) + return(result.capitalize()) def error(msg): return signup_tpl(alerts=[('error', msg, 'fadeOut')], str=i18n.str) @@ -167,13 +167,13 @@ def post_signup(): firstname = auto_complete('firstname') isFake = True else: - firstname = form('firstname').lower() + firstname = form('firstname').title() if len(form('surname')) == 0: surname = auto_complete('surname') isFake = True else: - surname = form('surname').lower() + surname = form('surname').title() email = form('email').lower() if not tools.email_validation(email): @@ -217,16 +217,16 @@ def post_edit_fullname(): if len(form('firstname')) < 3: return error(i18n.msg[11]) - elif not tools.input_validation(form('firstname')): + elif not tools.input_validation(form('firstname'), True): return error(i18n.msg[4]) if len(form('surname')) < 3: return error(i18n.msg[12]) - elif not tools.input_validation(form('surname')): + elif not tools.input_validation(form('surname'), True): return error(i18n.msg[5]) try: - edit_fullname(username, old_firstname, old_surname, form('firstname').lower(), form('surname').lower()) + edit_fullname(username, old_firstname, old_surname, form('firstname').title(), form('surname').title()) except Error as e: LOG.warning("Unsuccessful attempt to edit fullname for %s: %s" % (username, e)) return error(str(e)) diff --git a/data/invite-codes.db b/data/invite-codes.db index a3c0af1..7055ee7 100644 Binary files a/data/invite-codes.db and b/data/invite-codes.db differ diff --git a/libs/__pycache__/flist.cpython-39.pyc b/libs/__pycache__/flist.cpython-39.pyc index 69a8ea1..a49c14a 100644 Binary files a/libs/__pycache__/flist.cpython-39.pyc and b/libs/__pycache__/flist.cpython-39.pyc differ diff --git a/libs/__pycache__/helper.cpython-39.pyc b/libs/__pycache__/helper.cpython-39.pyc index ee422e3..b7a2554 100644 Binary files a/libs/__pycache__/helper.cpython-39.pyc and b/libs/__pycache__/helper.cpython-39.pyc differ diff --git a/libs/__pycache__/localization.cpython-39.pyc b/libs/__pycache__/localization.cpython-39.pyc index 1b78d5b..6d886df 100644 Binary files a/libs/__pycache__/localization.cpython-39.pyc and b/libs/__pycache__/localization.cpython-39.pyc differ diff --git a/libs/__pycache__/slist.cpython-39.pyc b/libs/__pycache__/slist.cpython-39.pyc index 845c99e..f9e30c6 100644 Binary files a/libs/__pycache__/slist.cpython-39.pyc and b/libs/__pycache__/slist.cpython-39.pyc differ diff --git a/libs/helper.py b/libs/helper.py index 0d71f0f..019c4f4 100644 --- a/libs/helper.py +++ b/libs/helper.py @@ -27,8 +27,12 @@ class Tools(): #form validation - def input_validation(self, e): - regex = r'^\w+$' + def input_validation(self, e, ws=None): + if ws: + #accepts whitespaces + regex = r'^\w+( \w+)*$' + else: + regex = r'^\w+$' return(bool(re.fullmatch(regex, e))) def email_validation(self, e): @@ -37,4 +41,4 @@ class Tools(): def pwd_validation(self, e): regex = r'^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*#?&])[A-Za-z\d@$!#%*?&]{8,18}$' - return(bool(re.fullmatch(regex, e))) \ No newline at end of file + return(bool(re.fullmatch(regex, e)))