[Python-modules-commits] [django-session-security] 12/18: Throttle lastActivity updates to once per second.

Jean-Michel Vourgère nirgal at moszumanska.debian.org
Wed Jun 17 10:37:52 UTC 2015


This is an automated email from the git hooks/post-receive script.

nirgal pushed a commit to branch debian/sid
in repository django-session-security.

commit 1513bd3db6a847cc1a1b383f60def4cc2a8fe12a
Author: Pēteris Caune <cuu508 at gmail.com>
Date:   Tue Jun 2 12:48:47 2015 +0300

    Throttle lastActivity updates to once per second.
    
    The throttling done here should be unnoticeable by end user: suppose the warning is visible on screen and user moves the mouse, and we're concerned there might be ~1s delay until the warning disappears. But, the warning being on the screen means the user has been idle for a good while. So the (now - this.lastActivity < 1000) check would fall through.
---
 session_security/static/session_security/script.js | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/session_security/static/session_security/script.js b/session_security/static/session_security/script.js
index f0977fa..15c4a08 100644
--- a/session_security/static/session_security/script.js
+++ b/session_security/static/session_security/script.js
@@ -66,7 +66,12 @@ yourlabs.SessionSecurity.prototype = {
 
     // Called by click, scroll, mousemove, keyup.
     activity: function() {
-        this.lastActivity = new Date();
+        var now = new Date();
+        if (now - this.lastActivity < 1000)
+            // Throttle these checks to once per second
+            return;
+
+        this.lastActivity = now;
 
         if (this.$warning.is(':visible')) {
             // Inform the server that the user came back manually, this should

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/django-session-security.git



More information about the Python-modules-commits mailing list