Automatic User Log Off

Possible to automatically log a user off of a client after a certain amount of time?

Hi Paul,

There is a default inactivity script that goes to a lockout screen, but can easily be changed to use system.security.logout, or system.security.switchUser if you want to put it to a default user.


1 Like

Great that gets me moving in the direction I want to go!

This is very helpful. I tried system.security.switchUser but keep getting login failed. Is there a way to assign a default user?

Sorry, been on vacation. There is no default user setting.

Did you set it up per the docs? (https://docs.inductiveautomation.com/display/DOC79/system.security.switchUser)

Does the user exist in the security profile you are using for the project?

If you setup your project for auto login (project properties), the user you've setup for auto login will be the default user as auto login will also occur when you logout.

Thanks Jordan. I eventually got it working a few days ago using a user profile. The docs did help.

1 Like

I know this is a very old thread, but if anyone comes here wanting a 10 minutes auto-logout script, here's the one I configured running as a 5 second Timer Client script:

# Check to see how long inactivity on the client has been active and
# if longer than 10 minutes, switch to the default operator account

if system.util.getInactivitySeconds() > 600 and system.security.getUsername() != "default username":
	system.security.switchUser("default username","default password")
1 Like

This topic is old enough that it is Vision-only implicitly (Perspective didn't exist then). Just to warn newer visitors that this is a Vision-only solution.

3 Likes

How would you go about logging out only once? I tested this out and the script runs continuously from inactivity.

Are you trying to log out of the application or go back to a default user?

Go back to a default user. I was able to figure it out by using a while loop instead of an "if" function.

Did you use @Samuel_Porter's example?

# Check to see how long inactivity on the client has been active and
# if longer than 10 minutes, switch to the default operator account

if system.util.getInactivitySeconds() > 600 and system.security.getUsername() != "default username":
	system.security.switchUser("default username","default password")
1 Like

Yes I did and changed the if to while.