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 import SIMPLE, SUBTREE, MODIFY_REPLACE, ALL_ATTRIBUTES
|
||||||
from ldap3.core.exceptions import LDAPBindError, LDAPConstraintViolationResult, \
|
from ldap3.core.exceptions import LDAPBindError, LDAPConstraintViolationResult, \
|
||||||
LDAPInvalidCredentialsResult, LDAPUserNameIsMandatoryError, \
|
LDAPInvalidCredentialsResult, LDAPUserNameIsMandatoryError, \
|
||||||
LDAPSocketOpenError, LDAPExceptionError
|
LDAPSocketOpenError, LDAPExceptionError, LDAPAttributeOrValueExistsResult
|
||||||
import logging
|
import logging
|
||||||
from os import getenv, environ, path
|
from os import getenv, environ, path
|
||||||
from libs import flist, slist
|
from libs import flist, slist
|
||||||
@ -148,7 +148,7 @@ def post_signup():
|
|||||||
result = random.choice(flist.firstname)
|
result = random.choice(flist.firstname)
|
||||||
elif arg == 'surname':
|
elif arg == 'surname':
|
||||||
result = random.choice(slist.surname)
|
result = random.choice(slist.surname)
|
||||||
return(result.lower())
|
return(result.capitalize())
|
||||||
|
|
||||||
def error(msg):
|
def error(msg):
|
||||||
return signup_tpl(alerts=[('error', msg, 'fadeOut')], str=i18n.str)
|
return signup_tpl(alerts=[('error', msg, 'fadeOut')], str=i18n.str)
|
||||||
@ -167,13 +167,13 @@ def post_signup():
|
|||||||
firstname = auto_complete('firstname')
|
firstname = auto_complete('firstname')
|
||||||
isFake = True
|
isFake = True
|
||||||
else:
|
else:
|
||||||
firstname = form('firstname').lower()
|
firstname = form('firstname').title()
|
||||||
|
|
||||||
if len(form('surname')) == 0:
|
if len(form('surname')) == 0:
|
||||||
surname = auto_complete('surname')
|
surname = auto_complete('surname')
|
||||||
isFake = True
|
isFake = True
|
||||||
else:
|
else:
|
||||||
surname = form('surname').lower()
|
surname = form('surname').title()
|
||||||
|
|
||||||
email = form('email').lower()
|
email = form('email').lower()
|
||||||
if not tools.email_validation(email):
|
if not tools.email_validation(email):
|
||||||
@ -217,16 +217,16 @@ def post_edit_fullname():
|
|||||||
|
|
||||||
if len(form('firstname')) < 3:
|
if len(form('firstname')) < 3:
|
||||||
return error(i18n.msg[11])
|
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])
|
return error(i18n.msg[4])
|
||||||
|
|
||||||
if len(form('surname')) < 3:
|
if len(form('surname')) < 3:
|
||||||
return error(i18n.msg[12])
|
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])
|
return error(i18n.msg[5])
|
||||||
|
|
||||||
try:
|
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:
|
except Error as e:
|
||||||
LOG.warning("Unsuccessful attempt to edit fullname for %s: %s" % (username, e))
|
LOG.warning("Unsuccessful attempt to edit fullname for %s: %s" % (username, e))
|
||||||
return error(str(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,7 +27,11 @@ class Tools():
|
|||||||
|
|
||||||
#form validation
|
#form validation
|
||||||
|
|
||||||
def input_validation(self, e):
|
def input_validation(self, e, ws=None):
|
||||||
|
if ws:
|
||||||
|
#accepts whitespaces
|
||||||
|
regex = r'^\w+( \w+)*$'
|
||||||
|
else:
|
||||||
regex = r'^\w+$'
|
regex = r'^\w+$'
|
||||||
return(bool(re.fullmatch(regex, e)))
|
return(bool(re.fullmatch(regex, e)))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user