cn hizki-larriz
This commit is contained in:
parent
6e24de0621
commit
3a0739b384
14
app.py
14
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))
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user