Skip to content

Commit

Permalink
Merge pull request #6 from bateller/patch-1
Browse files Browse the repository at this point in the history
Added Keep Alive Response Checking
  • Loading branch information
CrashSensei authored Mar 20, 2018
2 parents 1c40311 + 7ea199a commit 7e76944
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/jquery-idleTimeout-plus.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@
keepAliveUrl: window.location.href, // set URL to ping - does not apply if keepAliveInterval: false
keepAliveAjaxType: 'GET',
keepAliveAjaxData: '',

keepAliveResponse: false, // add ability to check keep alive's response. if user was logged out by other means, or something went wrong, redirect to keepAliveBadUrl - Set to false to disable KeepAliveBadUrl redirection
keepAliveBadUrl: window.location.href, // set URL to redirect to if keepAliveResponse wasn't what was expected and if keepAliveResponse isn't set to false

// Lock Screen settings
lockEnabled: false, // Set to true to enable lock screen before redirecting
lockTimeLimit: 7200, // 2 hrs
Expand Down Expand Up @@ -421,7 +423,12 @@
$.ajax({
type: config.keepAliveAjaxType,
url: config.keepAliveUrl,
data: config.keepAliveAjaxData
data: config.keepAliveAjaxData,
success: function(response){
if(config.keepAliveResponse !== false && $.trim(response) !== config.keepAliveResponse){
window.location.replace(config.keepAliveBadUrl);
}
}
});
}, config.keepAliveInterval);
}
Expand Down

0 comments on commit 7e76944

Please sign in to comment.