Disallow spaces in usernames

This commit is contained in:
rubenwardy 2021-03-02 22:36:21 +00:00
parent c11e5c1f99
commit df8ef542dd
2 changed files with 2 additions and 2 deletions

@ -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()])

@ -13,7 +13,7 @@ Register
<form action="" method="POST" class="form card-body" role="form">
{{ 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,