Skip to content

Commit

Permalink
Tweak logout template examples (#321)
Browse files Browse the repository at this point in the history
* Tweak logout template examples

* Add missing `csrf_token` / `csrf_input`
* Shorten snippets by removing `html`/`body` tags
* Fix Jinja2 example

* Don't call is_authenticated in Jinja2 template

`is_authenticated` is a property in recent Django versions (since 1.10) and can not be called since the release of Django 2.0
  • Loading branch information
jaap3 authored and akatsoulas committed Jan 10, 2020
1 parent 0de702e commit eb93c1a
Showing 1 changed file with 18 additions and 26 deletions.
44 changes: 18 additions & 26 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -159,37 +159,29 @@ Django templates example:

.. code-block:: html+django

<html>
<body>
{% if user.is_authenticated %}
<p>Current user: {{ user.email }}</p>
<form action="{% url 'oidc_logout' %}" method="post">
<input type="submit" value="logout">
</form>
{% else %}
<a href="{% url 'oidc_authentication_init' %}">Login</a>
{% endif %}
</body>
</html>

{% if user.is_authenticated %}
<p>Current user: {{ user.email }}</p>
<form action="{% url 'oidc_logout' %}" method="post">
{% csrf_token %}
<input type="submit" value="logout">
</form>
{% else %}
<a href="{% url 'oidc_authentication_init' %}">Login</a>
{% endif %}

Jinja2 templates example:

.. code-block:: html+jinja

<html>
<body>
{% if user.is_authenticated() %}
<p>Current user: {{ user.email }}</p>
<form action="{% url('oidc_logout') %}" method="post">
<input type="submit" value="logout">
</form>
{% else %}
<a href="{{ url('oidc_authentication_init') }}">Login</a>
{% endif %}
</body>
</html>

{% if request.user.is_authenticated %}
<p>Current user: {{ request.user.email }}</p>
<form action="{{ url('oidc_logout') }}" method="post">
{{ csrf_input }}
<input type="submit" value="logout">
</form>
{% else %}
<a href="{{ url('oidc_authentication_init') }}">Login</a>
{% endif %}

Additional optional configuration
=================================
Expand Down

0 comments on commit eb93c1a

Please sign in to comment.