Reactive web - idle timeout warning
Question

Good afternoon all.   We are working on our first reactive web application, and one of the requirements is to warn idle users that they will be logged out in 5 minutes and then again when they will be logged out in 1 minute.   From what I've seen the MAX_IDLE_TIME will handle the actual logout functionality but I have not been able to find a way to implement the warnings.   Any suggestions?

Also, just for my understanding.  If a user is on a particular screen and they reach the MAX_IDLE_TIME they will not automatically be redirected to the Login screen.   That will not occur until the next time the user attempts to fetch data from the server, is this accurate?

There is good information in that link, but I see nothing about popping a warning message when session expiration is imminent.

Did you find a solution to this?

No, I didn't.   I ended up creating a web block with some javascript that sets an interval and then warns the user that timeout is approaching or calls a client action that signs them out when it has expired.

Cheers for the response! I was looking at a similar issue and was hoping maybe you had found something. I may look to do the same then.

Here is the JavaScript, I just call it onReady of the web block.   The only issue I've noticed is that if the user does not have the tab active, the interval is still running in the browser but all of the events are essentially queued and executed when the tab/window regains focus.   So that's a little weird, if you find a better solution please let me know.


function idleTimeout (uTimeout, uWarning,uTimeoutAction,uWarningAction) { 

    var interval = 60000; 

    var IDLE_TIMEOUT = uTimeout; 

    var IDLE_WARNING = uTimeout - uWarning;

    var idleCounter = 0;

    var warningAction = uWarningAction;

    var timeoutAction = uTimeoutAction;

    var timeoutInterval;


    document.onmousemove = document.onkeypress = function () {

        idleCounter = 0;

    };

    


    timeoutInterval= window.setInterval(CheckIdleTime, interval);

        console.log("Created Interval:");

        function CheckIdleTime(){

        if (++idleCounter >= IDLE_TIMEOUT) {

            console.log('Triggering session timeout ');

            timeoutAction();

            clearInterval(timeoutInterval);

        } else if (idleCounter == IDLE_WARNING) {

            console.log('Triggering session warning ');

            warningAction();

        }

    }

    return timeoutInterval;


}



Thanks so much for this. I think we are looking to go with changing the outsystems timeout to match sso and maybe putting in a check role or something in an onrender function to trigger an authentication session. I'm not sure if that will help with your case but thought I'd let you know.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.