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> {{ form.username.label }}<br>
{{ field.label }}<br> {{ form.username() }}
{{ field() }} {% if form.username.errors %}
{% if field.errors %} <ul class="errors">
<ul class=errors> {% for error in form.username.errors %}
{% for category, message in messages %} <li class="danger">{{ error }}</li>
<li class="{{ category }}">{{ message }}</li> {% endfor %}
{% endfor %} </ul>
</ul> {% endif %}
{% endif %} </p>
</p> <p>
{% endfor %} {{ 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 %}
</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> {{ form.username.label }}
{{ field.label }}<br> {{ form.username() }}
{{ field() }} {% if form.username.errors %}
{% if field.errors %} <ul class="errors">
<ul class=errors> {% for error in form.username.errors %}
{% for error in field.errors %} <li class="danger">{{ error }}</li>
<li>{{ error }}</li>
{% endfor %} {% endfor %}
</ul> </ul>
{% endif %} {% endif %}
</p> </p>
{% endfor %} <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 %}
</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 %}