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> <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> <div class="dropdown-divider"></div>
{% endif %} {% 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> </div>
</li> </li>
{% else %} {% else %}
@ -82,7 +84,9 @@
</div> </div>
<li class="nav-item dropdown no-arrow"> <li class="nav-item dropdown no-arrow">
{% if user.is_authenticated %} {% 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> <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 %} {% 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> <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 %} {% endif %}