diff --git a/app.py b/app.py index fd46304..55244c9 100644 --- a/app.py +++ b/app.py @@ -111,8 +111,14 @@ def post_user(): def error(msg): return index_tpl(alerts=[('error', msg, 'fadeOut')], str=i18n.str) + def username_validation(e): + regex = r'^\w+$' + return(bool(re.fullmatch(regex, e))) + if len(form('username')) < 3: return error(i18n.msg[1]) + elif not username_validation(form('username')): + return error(i18n.msg[6]) if len(form('password')) < 1: return error(i18n.msg[2]) @@ -178,6 +184,8 @@ def post_signup(): surname = form('surname').lower() email = form('email').lower() + if not email_validation(email): + return error(i18n.msg[14]) if form('password') != form('confirm-password'): return error(i18n.msg[7])