Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix logging out before dialog counter has reached 0 #31

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions jquery-idleTimeout-for-testing.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
activityDetector,
startKeepSessionAlive, stopKeepSessionAlive, keepSession, keepAlivePing, // session keep alive
idleTimer, remainingTimer, checkIdleTimeout, checkIdleTimeoutLoop, startIdleTimer, stopIdleTimer, // idle timer
openWarningDialog, dialogTimer, checkDialogTimeout, startDialogTimer, stopDialogTimer, isDialogOpen, destroyWarningDialog, countdownDisplay, // warning dialog
openWarningDialog, dialogTimer, checkDialogTimeout, startDialogTimer, stopDialogTimer, isDialogOpen, destroyWarningDialog, countdownDisplay, dialogDisplaySeconds, // warning dialog
logoutUser,
checkForIframes, includeIframes, attachEventIframe; // iframes

Expand Down Expand Up @@ -231,7 +231,7 @@
checkDialogTimeout = function () {
var timeDialogTimeout = (store.get('idleTimerLastActivity') + (currentConfig.idleTimeLimit * 1000) + (currentConfig.dialogDisplayLimit * 1000));

if (($.now() > timeDialogTimeout) || (store.get('idleTimerLoggedOut') === true)) {
if ((($.now() > timeDialogTimeout) && (dialogDisplaySeconds <= 0)) || (store.get('idleTimerLoggedOut') === true)) {
console.log('warning dialog is open and user has remained inactive for the dialogDisplayLimit. Time to log out user.');
logoutUser();
} else {
Expand Down Expand Up @@ -271,15 +271,16 @@

// display remaining time on warning dialog
countdownDisplay = function () {
var dialogDisplaySeconds = currentConfig.dialogDisplayLimit, mins, secs;
dialogDisplaySeconds = currentConfig.dialogDisplayLimit;
var mins, secs;

remainingTimer = setInterval(function () {
mins = Math.floor(dialogDisplaySeconds / 60); // minutes
if (mins < 10) { mins = '0' + mins; }
secs = dialogDisplaySeconds - (mins * 60); // seconds
if (secs < 10) { secs = '0' + secs; }
$('#countdownDisplay').html(mins + ':' + secs);
dialogDisplaySeconds -= 1;
if (dialogDisplaySeconds) { dialogDisplaySeconds -= 1; }
}, 1000);
};

Expand Down
9 changes: 5 additions & 4 deletions jquery-idleTimeout-iframes.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
activityDetector,
startKeepSessionAlive, stopKeepSessionAlive, keepSession, keepAlivePing, // session keep alive
idleTimer, remainingTimer, checkIdleTimeout, checkIdleTimeoutLoop, startIdleTimer, stopIdleTimer, // idle timer
openWarningDialog, dialogTimer, checkDialogTimeout, startDialogTimer, stopDialogTimer, isDialogOpen, destroyWarningDialog, countdownDisplay, // warning dialog
openWarningDialog, dialogTimer, checkDialogTimeout, startDialogTimer, stopDialogTimer, isDialogOpen, destroyWarningDialog, countdownDisplay, dialogDisplaySeconds, // warning dialog
logoutUser,
checkForIframes, includeIframes, attachEventIframe; // iframes

Expand Down Expand Up @@ -203,7 +203,7 @@
checkDialogTimeout = function () {
var timeDialogTimeout = (store.get('idleTimerLastActivity') + (currentConfig.idleTimeLimit * 1000) + (currentConfig.dialogDisplayLimit * 1000));

if (($.now() > timeDialogTimeout) || (store.get('idleTimerLoggedOut') === true)) {
if ((($.now() > timeDialogTimeout) && (dialogDisplaySeconds <= 0)) || (store.get('idleTimerLoggedOut') === true)) {
logoutUser();
}
};
Expand Down Expand Up @@ -236,15 +236,16 @@
};

countdownDisplay = function () {
var dialogDisplaySeconds = currentConfig.dialogDisplayLimit, mins, secs;
dialogDisplaySeconds = currentConfig.dialogDisplayLimit;
var mins, secs;

remainingTimer = setInterval(function () {
mins = Math.floor(dialogDisplaySeconds / 60); // minutes
if (mins < 10) { mins = '0' + mins; }
secs = dialogDisplaySeconds - (mins * 60); // seconds
if (secs < 10) { secs = '0' + secs; }
$('#countdownDisplay').html(mins + ':' + secs);
dialogDisplaySeconds -= 1;
if (dialogDisplaySeconds) { dialogDisplaySeconds -= 1; }
}, 1000);
};

Expand Down
9 changes: 5 additions & 4 deletions jquery-idleTimeout.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
activityDetector,
startKeepSessionAlive, stopKeepSessionAlive, keepSession, keepAlivePing, // session keep alive
idleTimer, remainingTimer, checkIdleTimeout, checkIdleTimeoutLoop, startIdleTimer, stopIdleTimer, // idle timer
openWarningDialog, dialogTimer, checkDialogTimeout, startDialogTimer, stopDialogTimer, isDialogOpen, destroyWarningDialog, countdownDisplay, // warning dialog
openWarningDialog, dialogTimer, checkDialogTimeout, startDialogTimer, stopDialogTimer, isDialogOpen, destroyWarningDialog, countdownDisplay, dialogDisplaySeconds, // warning dialog
logoutUser;

//##############################
Expand Down Expand Up @@ -190,7 +190,7 @@
checkDialogTimeout = function () {
var timeDialogTimeout = (store.get('idleTimerLastActivity') + (currentConfig.idleTimeLimit * 1000) + (currentConfig.dialogDisplayLimit * 1000));

if (($.now() > timeDialogTimeout) || (store.get('idleTimerLoggedOut') === true)) {
if ((($.now() > timeDialogTimeout) && (dialogDisplaySeconds <= 0)) || (store.get('idleTimerLoggedOut') === true)) {
logoutUser();
}
};
Expand Down Expand Up @@ -223,15 +223,16 @@
};

countdownDisplay = function () {
var dialogDisplaySeconds = currentConfig.dialogDisplayLimit, mins, secs;
dialogDisplaySeconds = currentConfig.dialogDisplayLimit;
var mins, secs;

remainingTimer = setInterval(function () {
mins = Math.floor(dialogDisplaySeconds / 60); // minutes
if (mins < 10) { mins = '0' + mins; }
secs = dialogDisplaySeconds - (mins * 60); // seconds
if (secs < 10) { secs = '0' + secs; }
$('#countdownDisplay').html(mins + ':' + secs);
dialogDisplaySeconds -= 1;
if (dialogDisplaySeconds) { dialogDisplaySeconds -= 1; }
}, 1000);
};

Expand Down