Show current logged in user

Two part question

  1. I am trying to setup so if an Admin Account is inactive for set time they are logged out and an Operator Account is logged in.
  2. How can we show the current user logged in?

Thanks

In Vision, this sort of information is available in the [System] tag provider. Combine that with a client timer event that monitors the inactivity time.

1 Like

Hi Larry,
You have the Inactivity timeout properties in the Project properties in the designer.

To show the current user logged in:

  • For Vision you got this in System tag provider.
  • For Perspective you got this in the sessions properties

Regards,

1 Like

That is incorrect. Use a Client Timer script to switch away from an admin user.

5 Likes

Jordan,

I'm assuming you replace (username, password) with actual user and password? I've tried this several times with no luck. Thanks.

That is correct.

Did you try this in a running client? It won't work in the designer.

1 Like

Yessir. I set the script up in Client Event Scripts-Timers, Apply/OK and save. Run the Client and no luck. I have even tried shutting the client down and restarting to see if it needed that for the script to run. I appreciate the help.

Can you show your work, as my teachers would say?

1 Like

Sure can. I have tried with and without the getUsername

if system.util.getInactivitySeconds() > 30 and system.security.getUsername() != Admin:
system.security.switchUser(Operator, operator)

The username and passwords need to be in quotes.

Also, when posting code, plese pate it, highlight it, then use the </> button to format it. I can't tell if there is an indent on the second line or not.

3 Likes

Can you edit your post so the code is in the preformatted style?
Like this:
opera_QqsmLlUzDG
Just to be sure, on this part

And this part:

Admin and Operator,operator are string variables that were defined earlier and you didn't show it in the snippet of code, right?
Otherwise i don't see anything obviously wrong

1 Like

You also need to check that the user is not already Operator, or the timer will try to switch user over and over and over.

2 Likes

That was the ticket. Thanks again.

1 Like

Hey,
Hope you all are fine, i am stuck in a problem.
I want to show the current user who is login in a label which is in nav bar so can anyone help me how to do it
image

If you are using perspective, session.props.auth.user will contain the current user's username and other information. If you are in vision, the [system]Client/User folder in the tag browser should contain username, roles and other information you can use.

Bind the label's text value to either the session.props.auth.user.username property if you are in perspective or to the [system]Client/User/Username tag if you are in vision.

2 Likes