From df8ef542ddaca866bbb0ec7d80386b14db81eb5b Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Tue, 2 Mar 2021 22:36:21 +0000 Subject: [PATCH] Disallow spaces in usernames --- app/blueprints/users/account.py | 2 +- app/templates/users/register.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/blueprints/users/account.py b/app/blueprints/users/account.py index e546d486..780a6a72 100644 --- a/app/blueprints/users/account.py +++ b/app/blueprints/users/account.py @@ -102,7 +102,7 @@ def logout(): class RegisterForm(FlaskForm): display_name = StringField("Display Name", [Optional(), Length(1, 20)], filters=[lambda x: nonEmptyOrNone(x)]) username = StringField("Username", [InputRequired(), - Regexp("^[a-zA-Z0-9._ -]+$", message="Only a-zA-Z0-9._ allowed")]) + Regexp("^[a-zA-Z0-9._-]+$", message="Only a-zA-Z0-9._ allowed")]) email = StringField("Email", [InputRequired(), Email()]) password = PasswordField("Password", [InputRequired(), Length(6, 100)]) agree = BooleanField("I agree", [Required()]) diff --git a/app/templates/users/register.html b/app/templates/users/register.html index 78fd9674..82657c1f 100644 --- a/app/templates/users/register.html +++ b/app/templates/users/register.html @@ -13,7 +13,7 @@ Register
{{ form.hidden_tag() }} - {{ render_field(form.username, pattern="[a-zA-Z0-9._ -]+", title=_("Only a-zA-Z0-9._ allowed"), + {{ render_field(form.username, pattern="[a-zA-Z0-9._-]+", title=_("Only a-zA-Z0-9._ allowed"), hint=_("Only alphanumeric characters, periods, underscores, and minuses are allowed (a-zA-Z0-9._)")) }} {{ render_field(form.display_name,