Add an 'auto log-off' of the system after 10 minutes. This promotes security measures and ensures no one can stay logged in consistently (or walk away leaving protected information available).
I used the code that Sam Carney posted and it works great. However, is there a way to only run the script when a user is logged in? Otherwise the script keeps trying to run after logout.
Thanks in advance.
The original request on this thread was for an inactivity logout feature (auto log-off) and we're excited to announce that this feature is now available for Pro, Corporate and Plus plans!
You can read about how to set up Inactivity Logout under your app's User Logins in our "Live App Security Settings: Inactivity Logout" article.
For the other feature requests contained within this thread, please be sure to add your vote to other forum posts that cover your request or if one doesn't exist, be sure to add one.
Hi everyone,
I'm soliciting again on this feature request forum, as I received positive feedback from Knack users in regards to the Tracking User Logins feature thread. We've developed a script that does the following:
1. The user is automatically logged out of the system after a period of inactivity (X minutes) determined by a variable in the script you can update yourself.
2. The user is automatically logged out of the system the moment they close the webpage or browser (this includes refreshing the webpage).
We can install the patch on your system for $267.87 USD. If you are interested, please give me an email at RobertSmith@datacove.ca and we can get that in place for you.
Thanks again,
Robert
This works great. Thank you. However, this only works if the page is left open and idle. Is there a way to be able to automatically log the user out when they close the page?
That helped a lot. Thank you!!!
Hi Campguy23
You want to add that script withi a scene handler. Something like this:
$(document).on('knack-page-render.scene_123', function () {
window.onload = timedRefresh(30000);
});
function timedRefresh(timeoutPeriod) {
setTimeout("location.reload(true);",timeoutPeriod);
}
Please chane the "scene_123" for the correct value.
Hope these helps.
I've managed to get ALL my pages refreshing with the following script:
function timedRefresh(timeoutPeriod) {
setTimeout("location.reload(true);",timeoutPeriod);
}
window.onload = timedRefresh(30000);
Now if someone could just help me figure out how to get this script to work on only ONE of my pages, I'll be set!
Sam, how might the script look if we wanted the page to refresh ie every time an inline edit or record change was made on a table within the page?
Or even a script with just a straight auto-refresh of the page at a specified time interval would be very helpful.
Thanks in advance!
I am interested in this function. Where would I place this code?
Hi Sam, thanks for your reply. I manage to get it working. Wrapped the code around the $(document).ready(function() {}) Jquery handler and it worked!
Cheers for asking!
Alejandro
Alejandro,
Do you mind posting the exact code you are using? I’ve had mine working successfully for about a month now.
Hello friends, wonder if this auto log-off ever worked? I tested Sam's javascript, nonetheless the setInterval method doesn't seem to be looping ... Wonder if it's something related to Knack's platform?
Will appreciate your thoughts
Best
Alejandro
Try this.
var idleTime = 0;
$(document).ready(function () {
//Increment the idle time counter every minute.
var idleInterval = setInterval(timerIncrement, 60000); // 1 minute//Zero the idle timer on mouse movement. $(this).mousemove(function (e) { idleTime = 0; }); $(this).keypress(function (e) { idleTime = 0; });
});
function timerIncrement() {
idleTime = idleTime + 1;
if (idleTime > 19) { // 20 minutes
$(".kn-log-out").trigger(“click”);
}
}
(I don't know javascript well, so your mileage may vary.)
I assume this is possible with a little javascript. Perhaps something like this?
window.setTimeout(function(){ window.location.href = "https://builder.knackhq.com/cccatering/catering-db#logout";</span><span>}, </span><span>60000</span><span>);</span></pre>