mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-12-25 02:44:18 +00:00
Add registration form, view, template
This commit is contained in:
parent
999e51bcc5
commit
d1d5e5f114
@ -14,7 +14,25 @@ class LoginForm(FlaskForm):
|
|||||||
|
|
||||||
|
|
||||||
class RegistrationForm(FlaskForm):
|
class RegistrationForm(FlaskForm):
|
||||||
email = StringField('Email', validators=[DataRequired(), Length(1, 64), Email()])
|
email = StringField('Email', validators=[DataRequired(), Length(1, 64),
|
||||||
|
Email()])
|
||||||
|
username = StringField('Username', validators=[
|
||||||
|
DataRequired(), Length(1, 64),
|
||||||
|
Regexp('^[A-Za-z][A-Za-z0-9_.]*$', 0,
|
||||||
|
'Usernames must have only letters, numbers, dots or '
|
||||||
|
'underscores')])
|
||||||
|
password = PasswordField('Password', validators=[
|
||||||
|
DataRequired(), EqualTo('password2', message='Passwords must match.')])
|
||||||
|
password2 = PasswordField('Confirm password', validators=[DataRequired()])
|
||||||
|
submit = SubmitField('Register')
|
||||||
|
|
||||||
|
def validate_email(self, field):
|
||||||
|
if User.query.filter_by(email=field.data.lower()).first():
|
||||||
|
raise ValidationError('Email already registered.')
|
||||||
|
|
||||||
|
def validate_username(self, field):
|
||||||
|
if User.query.filter_by(username=field.data).first():
|
||||||
|
raise ValidationError('Username already in use.')
|
||||||
|
|
||||||
|
|
||||||
class PasswordResetRequestForm(FlaskForm):
|
class PasswordResetRequestForm(FlaskForm):
|
||||||
|
@ -2,34 +2,48 @@
|
|||||||
|
|
||||||
{% block page_content %}
|
{% block page_content %}
|
||||||
<div class="col s12">
|
<div class="col s12">
|
||||||
<div class="row">
|
<div class="card large">
|
||||||
<div class="card medium">
|
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
<span class="card-title">Register</span>
|
<span class="card-title">Register</span>
|
||||||
<form>
|
<form method="POST">
|
||||||
<div class="input-field col s6">
|
{{ form.hidden_tag() }}
|
||||||
<input id="first-name" type="text" class="validate">
|
<div class="input-field">
|
||||||
<label for="first-name">First Name</label>
|
<i class="material-icons prefix">account_circle</i>
|
||||||
|
{{ form.username(class='validate') }}
|
||||||
|
{{ form.username.label }}
|
||||||
|
{% for error in form.username.errors %}
|
||||||
|
<span class="helper-text" style="color:red;">{{ error }}</span>
|
||||||
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
<div class="input-field col s6">
|
<div class="input-field">
|
||||||
<input id="last-name" type="text" class="validate">
|
<i class="material-icons prefix">vpn_key</i>
|
||||||
<label for="last-name">Last Name</label>
|
{{ form.password(class='validate') }}
|
||||||
|
{{ form.password.label }}
|
||||||
|
{% for error in form.password.errors %}
|
||||||
|
<span class="helper-text" style="color:red;">{{ error }}</span>
|
||||||
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="input-field">
|
||||||
<div class="input-field col s12">
|
<i class="material-icons prefix">vpn_key</i>
|
||||||
<input id="password" type="password" class="validate">
|
{{ form.password2(class='validate') }}
|
||||||
<label for="password">Password</label>
|
{{ form.password2.label }}
|
||||||
|
{% for error in form.password2.errors %}
|
||||||
|
<span class="helper-text" style="color:red;">{{ error }}</span>
|
||||||
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
<div class="input-field ">
|
||||||
|
<i class="material-icons prefix">email</i>
|
||||||
|
{{ form.email(class='validate', type='email') }}
|
||||||
|
{{ form.email.label }}
|
||||||
|
{% for error in form.email.errors %}
|
||||||
|
<span class="helper-text" style="color:red;">{{ error }}</span>
|
||||||
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="card-action">
|
||||||
<div class="input-field col s12">
|
{{ form.submit(class='btn right') }}
|
||||||
<input id="email" type="email" class="validate">
|
|
||||||
<label for="email">Email</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
<li><a href="{{ url_for('auth.logout') }}"><i class="material-icons">chevron_left</i>Log out</a></li>
|
<li><a href="{{ url_for('auth.logout') }}"><i class="material-icons">chevron_left</i>Log out</a></li>
|
||||||
{% else %}
|
{% else %}
|
||||||
<li><a href="{{ url_for('auth.login') }}"><i class="material-icons">chevron_right</i>Log in</a></li>
|
<li><a href="{{ url_for('auth.login') }}"><i class="material-icons">chevron_right</i>Log in</a></li>
|
||||||
|
<li><a href="{{ url_for('auth.register') }}"><i class="material-icons">chevron_right</i>Register</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</ul>
|
</ul>
|
||||||
<div id="nav-settings-dropdown" class="dropdown-content grey-text text-darken-4">
|
<div id="nav-settings-dropdown" class="dropdown-content grey-text text-darken-4">
|
||||||
|
BIN
data_dev.sqlite
BIN
data_dev.sqlite
Binary file not shown.
Loading…
Reference in New Issue
Block a user