fix csrf token showing

This commit is contained in:
Jack Eilles 2023-12-26 19:26:19 +00:00
parent 40ab9fdbb1
commit 66d57eeab7
2 changed files with 74 additions and 27 deletions

View file

@ -3,19 +3,31 @@
{% block content %} {% block content %}
<h1>Login</h1> <h1>Login</h1>
<form action="" method="post"> <form action="" method="post">
{{ form.hidden_tag() }} {{ form.csrf_token() }}
{% for field in form %}
<p> <p>
{{ field.label }}<br> {{ form.username.label }}<br>
{{ field() }} {{ form.username() }}
{% if field.errors %} {% if form.username.errors %}
<ul class=errors> <ul class="errors">
{% for category, message in messages %} {% for error in form.username.errors %}
<li class="{{ category }}">{{ message }}</li> <li class="danger">{{ error }}</li>
{% endfor %} {% endfor %}
</ul> </ul>
{% endif %} {% endif %}
</p> </p>
<p>
{{ form.password.label }}<br>
{{ form.password() }}
{% if form.password.errors %}
<ul class="errors">
{% for error in form.password.errors %}
<li class="danger">{{ error }}</li>
{% endfor %} {% endfor %}
</ul>
{% endif %}
</p>
<p>
<input type="submit" value="Login">
</p>
</form> </form>
{% endblock %} {% endblock %}

View file

@ -3,19 +3,54 @@
{% block content %} {% block content %}
<h1>Register</h1> <h1>Register</h1>
<form action="" method="post"> <form action="" method="post">
{{ form.hidden_tag() }} {{ form.csrf_token }}
{% for field in form %}
<p> <p>
{{ field.label }}<br> {{ form.username.label }}
{{ field() }} {{ form.username() }}
{% if field.errors %} {% if form.username.errors %}
<ul class=errors> <ul class="errors">
{% for error in field.errors %} {% for error in form.username.errors %}
<li>{{ error }}</li> <li class="danger">{{ error }}</li>
{% endfor %} {% endfor %}
</ul> </ul>
{% endif %} {% endif %}
</p> </p>
<p>
{{ form.password.label }}
{{ form.password() }}
{% if form.password.errors %}
<ul class="errors">
{% for error in form.password.errors %}
<li class="danger">{{ error }}</li>
{% endfor %} {% endfor %}
</ul>
{% endif %}
</p>
<p>
{{ form.password2.label }}
{{ form.password2() }}
{% if form.password2.errors %}
<ul class="errors">
{% for error in form.password2.errors %}
<li class="danger">{{ error }}</li>
{% endfor %}
</ul>
{% endif %}
</p>
<p>
{{ form.tnc.label }}
{{ form.tnc() }}
{% if form.tnc.errors %}
<ul class="errors">
{% for error in form.tnc.errors %}
<li class="danger">{{ error }}</li>
{% endfor %}
</ul>
{% endif %}
</p>
<p>
<input type="submit" value="Register">
</p>
</form> </form>
{% endblock %} {% endblock %}