2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-19 05:25:42 +00:00

[FR] User sessions

Fixes #2327
This commit is contained in:
Matthias
2021-11-26 23:56:24 +01:00
parent 82d5952ddd
commit db1a434f81
5 changed files with 76 additions and 2 deletions

View File

@ -4,6 +4,7 @@
{% load inventree_extras %}
{% load socialaccount %}
{% load crispy_forms_tags %}
{% load user_sessions i18n %}
{% block label %}account{% endblock %}
@ -173,6 +174,47 @@
</div>
<div class='panel-heading'>
<h4>{% trans "Active Sessions" %}</h4>
</div>
<div>
{% trans "<em>unknown on unknown</em>" as unknown_on_unknown %}
{% trans "<em>unknown</em>" as unknown %}
<table class="table table-striped table-condensed">
<thead>
<tr>
<th>{% trans "IP Address" %}</th>
<th>{% trans "Device" %}</th>
<th>{% trans "Last Activity" %}</th>
</tr>
</thead>
{% for object in session_list %}
<tr {% if object.session_key == session_key %}class="active"{% endif %}>
<td>{{ object.ip }}</td>
<td>{{ object.user_agent|device|default_if_none:unknown_on_unknown|safe }}</td>
<td>
{% if object.session_key == session_key %}
{% blocktrans with time=object.last_activity|timesince %}{{ time }} ago (this session){% endblocktrans %}
{% else %}
{% blocktrans with time=object.last_activity|timesince %}{{ time }} ago{% endblocktrans %}
{% endif %}
</td>
</tr>
{% endfor %}
</table>
{% if session_list.count > 1 %}
<form method="post" action="{% url 'session_delete_other' %}">
{% csrf_token %}
<p>{% blocktrans %}You can also end all other sessions but the current.
This will log you out on all other devices.{% endblocktrans %}
<button type="submit" class="btn btn-sm btn-default btn-danger">{% trans "End All Other Sessions" %}</button></p>
</form>
{% endif %}
</div>
<div class='panel-heading'>
<h4>{% trans "Language Settings" %}</h4>
</div>