yourlabs / django-session-security

A little javascript and middleware work together to ensure that the user was active during the past X minutes in any tab he has open. Otherwise, display a warning leaving a couple of minutes to show any kind of activity like moving the mouse. Otherwise, logout the user.
http://django-session-security.rtfd.org
MIT License
309 stars 142 forks source link

Added seconds countdown if "counterElementID" is set #135

Closed mwhawkins closed 5 months ago

mwhawkins commented 4 years ago

This adds a counter to count down the number of seconds remaining until expiration if counterElementID is set, e.g.:

<h3>{% trans 'Your session is about to expire in' %} <span id="in_seconds"></span> {% trans 'seconds' %}</h3>

<script type="text/javascript">
            var sessionSecurity = new yourlabs.SessionSecurity({
                pingUrl: '{% url 'session_security_ping' %}',
                warnAfter: {{ request|warn_after|unlocalize }},
                expireAfter: {{ request|expire_after|unlocalize }},
                confirmFormDiscard: "{% trans 'You have unsaved changes in a form of this page.' %}",
                counterElementID: "in_seconds"
            });
        </script>

image

its4net commented 2 years ago

This would be very helpful. Please merge.

mpasternak commented 2 years ago

I love it! @jpic , what do you think?

jpic commented 5 months ago

Working great, enabled by default, except made sure we don't introduce a new translatable string, merged manually