Timeout After Inactivity

Hi there,

Since I was quite interested in something like this as well, after I read your post, I decided to see if I could cook something up. If you need it to be ‘dead on’, I’m not sure this is the right approach, but since it’s meant to logout a user after inactivity, a couple seconds left or right wouldn’t matter.

A post I read from @benjamenus really helped me nail it down properly. He wrote:

So I created something using the same method. This sollution also contains a workflow that would show a pop-up ‘x’ amount of seconds before the user gets logged out, giving the an opportunity to tell the app that they are still live and kicking. To have this sollution work properly globally on the app I recommend putting these workflows in a repeating element of your app like your header or footer (the header is probably more ‘elegant’/‘expected’).

Step 1:
Create a workflow in your repeating element

WHEN: Page is loaded and when current user is logged in
THEN: Make changes to the user → Change another field → ActivityTime(number) =

Where is the amount of seconds you are going to set before the user gets logged out.

Step 2:
Create a second workflow in your repeating element

WHEN: Do every 5 seconds and when Current user is logged in
THEN: Make changes to the user → Change Another field → ActivityTime = Current User’s ActivityTime - 5

This will count down the timer 5 seconds at a time. I guess that performance wise you could screw this up to 15 or 30 seconds asuming that you would accept the increased ‘delay’.

Step 3:
Create another workflow in your repeating element

WHEN: Do every 15 seconds and when Current User’s ActivityTime <= and current user is logged in.
THEN: Show Popup

The popup is something you’d need to build with a button that has it’s own workflow. The workflow of the button would either redirect them to the homepage (very annoying UX wise) or simply reset the countdown by invoking the same principal as the workflow in step 1.

is the amount of seconds before you show the warning pop-up.

Step 4:
Create another workflow in your repeating element.

WHEN: Do every 15 seconds and when Current User’s ActivityTime <= 0 and current user is logged in.
THEN: Log the user out (and optionally redirect them to a different page).

This would eventually log out the user and redirect them to the homepage of your app.


I hope that my sollution is something you can use in your app, and that my description was clear and understandable enough for you to reproduce it in your app.

Regards,
Olrik

EDIT: Changed some stuff to be more effecient.

10 Likes