orangehill / bootstrap-session-timeout

Session timeout and keep-alive control with a nice Bootstrap warning dialog.
MIT License
159 stars 110 forks source link

Timer stop after Redir #36

Open shashankkrjain opened 8 years ago

shashankkrjain commented 8 years ago

The timer should stop after onRedir function has finished execution. Effectively when the whole sessionTimeout cycle has finished once.

The problem is, in our application, we show lock screen modal on the same page, and not redirect user to lock screen page. Now, what happens is, the timer keeps running and shows session timeout warning again.

sandeepjadala commented 8 years ago

Check if your lock screen modal exists in document then don't startSessionTimer in bootstrap-session-timer.js. Hope this helps you.

function startSessionTimer() { //***check if login dialog exists then don't reset timer**** if ($('#loginModal').length == 0) {

            // Clear session timer
            clearTimeout(timer);
            if (opt.countdownMessage || opt.countdownBar) {
                startCountdownTimer('session', true);
            }

            if (typeof opt.onStart === 'function') {
                opt.onStart(opt);
            }

            // If keepAlive option is set to "true", ping the "keepAliveUrl" url
            if (opt.keepAlive) {
                keepAlive();
            }

            // Set session timer
            timer = setTimeout(function () {
                // Check for onWarn callback function and if there is none, launch dialog
                if (typeof opt.onWarn !== 'function') {
                    $('#session-timeout-dialog').modal('show');
                } else {
                    opt.onWarn(opt);
                }
                // Start dialog timer
                startDialogTimer();
            }, opt.warnAfter);

        }
    }