Skip to content

Commit

Permalink
Update logout to be a POST
Browse files Browse the repository at this point in the history
Django needs logout to be a POST now, so we need
CSRF tokens
  • Loading branch information
mrchrisadams committed May 6, 2024
1 parent 0cf0a8b commit 3f09f80
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion apps/accounts/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,12 @@
{% if request.user.is_authenticated %}
<span>Hello {{ request.user.username }}</span>
<span role="img" aria-label="waving hand">👋</span>
<span class="pl-3"><a href="{% url 'logout' %}">Log out</a></span>
<form class="inline" method="POST" action="{% url 'logout' %}">
{% csrf_token %}
<span class="pl-3">
<button> Log out</button>
</span>
</form>
{% else %}
<a href="{% url 'login' %}">Log in</a>
{% endif %}
Expand Down

0 comments on commit 3f09f80

Please sign in to comment.