Add username validation to signup page

This commit is contained in:
rubenwardy 2021-02-22 23:45:20 +00:00
parent 3ed73c4145
commit 77dcb85912
5 changed files with 20 additions and 37 deletions

@ -100,7 +100,8 @@ def logout():
class RegisterForm(FlaskForm):
username = StringField("Username", [InputRequired()])
username = StringField("Username", [InputRequired(),
Regexp("^[a-zA-Z0-9._ -]+$", message="Only a-zA-Z0-9._ allowed")])
email = StringField("Email", [InputRequired(), Email()])
password = PasswordField("Password", [InputRequired(), Length(6, 100)])
submit = SubmitField("Register")

@ -5,22 +5,22 @@ Create Account from Forums User
{% endblock %}
{% block content %}
<h1>{{ self.title() }}</h1>
<h1>{{ self.title() }}</h1>
<h2>{{ _("Confirm Your Account") }}</h2>
<h2>{{ _("Confirm Your Account") }}</h2>
<p>
You'll need to use prove that you have access to your forum account using one of the options below.<br>
This is so ContentDB can link your account to your forum account.
</p>
<p>
You'll need to use prove that you have access to your forum account using one of the options below.<br>
This is so ContentDB can link your account to your forum account.
</p>
<p>
Don't have a forums account?
You can still <a href="{{ url_for('users.register') }}">sign up without one</a>.
</p>
<p>
Don't have a forums account?
You can still <a href="{{ url_for('users.register') }}">sign up without one</a>.
</p>
<div class="row mt-5">
<div class="col-sm-6">
<div class="row mt-5">
<div class="col-sm-6">
<div class="card">
<div class="card-header">
<span class="badge badge-pill badge-dark mr-2">Option 1</span>
@ -48,9 +48,9 @@ Create Account from Forums User
<input class="btn btn-primary" type="submit" value="Next: log in with GitHub">
</form>
</div>
</div>
</div>
<div class="col-sm-6">
<div class="col-sm-6">
<div class="card">
<div class="card-header">
<span class="badge badge-pill badge-dark mr-2">Option 2</span>
@ -91,23 +91,6 @@ Create Account from Forums User
<input class="btn btn-primary" type="submit" value="Next">
</form>
</div>
</div>
{# <div class="col-sm-4">#}
{# <div class="card">#}
{# <div class="card-header">#}
{# Email/password sign up#}
{# </div>#}
{##}
{# <div class="card-body">#}
{# <p>#}
{# If you have a forum account, please use one of the other two#}
{# options.#}
{# </p>#}
{##}
{# <a class="btn btn-primary" href="{{ url_for('users.register') }}">Register</a>#}
{# </div>#}
{# </div>#}
{# </div>#}
</div>
</div>
{% endblock %}

@ -7,13 +7,13 @@ Register
{% block content %}
{% from "macros/forms.html" import render_field, render_checkbox_field, render_submit_field %}
<div class="card">
<div class="card w-50 text-left" style="margin: 2em auto;">
<h2 class="card-header">{{ _("Register") }}</h2>
<form action="" method="POST" class="form card-body" role="form">
{{ form.hidden_tag() }}
{{ render_field(form.username) }}
{{ render_field(form.username, pattern="[a-zA-Z0-9._ -]+", title="Only a-zA-Z0-9._ allowed") }}
{{ render_field(form.email) }}
{{ render_field(form.password) }}

@ -33,7 +33,6 @@ gitdb==4.0.5
GitHub-Flask==3.2.0
GitPython==3.1.12
gunicorn==20.0.4
idna==3.1
importlib-metadata==3.4.0
iniconfig==1.1.1
itsdangerous==1.1.0

@ -6,4 +6,4 @@
# docker-compose directly: docker-compose up --build
#
sudo docker-compose up --build -d --scale worker=2
docker-compose up --build -d --scale worker=2