django-session-security icon indicating copy to clipboard operation
django-session-security copied to clipboard

Added seconds countdown if "counterElementID" is set

Open mwhawkins opened this issue 4 years ago • 2 comments

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

mwhawkins avatar Jul 10 '20 01:07 mwhawkins

This would be very helpful. Please merge.

its4net avatar Nov 03 '21 18:11 its4net

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

mpasternak avatar Nov 08 '21 08:11 mpasternak

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

jpic avatar Apr 12 '24 09:04 jpic