fix logout in Django 5 with POST action instead of GET

This commit is contained in:
Benbb96 2024-05-07 14:54:05 +02:00 committed by GitHub
parent ba9935e792
commit 6fe5f1681f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -58,7 +58,9 @@
<a class="dropdown-item" href='{% url 'helpdesk:system_settings' %}'><i class="fas fa-fw fa-cogs"></i> {% trans "System Settings" %}</a>
<div class="dropdown-divider"></div>
{% endif %}
<a class="dropdown-item" href="{% url 'helpdesk:logout' %}"><i class="fas fa-fw fa-sign-out-alt"></i> {% trans "Logout" %}</a>
<form action="{% url 'helpdesk:logout' %}" method="post">{% csrf_token %}
<button type="submit" class="dropdown-item"><i class="fas fa-fw fa-sign-out-alt"></i> {% trans "Logout" %}</button>
</form>
</div>
</li>
{% else %}
@ -82,8 +84,10 @@
</div>
<li class="nav-item dropdown no-arrow">
{% if user.is_authenticated %}
<a class="nav-link dropdown-toggle" href="{% url 'helpdesk:logout' %}" id="userDropdown" role="button" aria-haspopup="true" aria-expanded="false"><i class="fas fa-fw fa-sign-out-alt"></i> {% trans "Logout" %}</a>
{% else %}
<form action="{% url 'helpdesk:logout' %}" method="post">{% csrf_token %}
<button type="submit" class="nav-link dropdown-toggle" id="userDropdown" role="button" aria-haspopup="true" aria-expanded="false"><i class="fas fa-fw fa-sign-out-alt"></i> {% trans "Logout" %}</button>
</form>
{% else %}
<a class="nav-link dropdown-toggle" href="{% url 'helpdesk:login' %}?next={% if next %}{{ next|escape }}{% else %}{% url 'helpdesk:home' %}{% endif %}" id="userDropdown" role="button" aria-haspopup="true" aria-expanded="false"><i class="fas fa-fw fa-sign-in-alt"></i> {% trans "Log In" %}</a>
{% endif %}
</li>