Switch Users in Vision

Hello,

I am needing assistance on how to use "System.security.Switchuser" function. I am having no luck on how to switch users within a client. I've used the example in the manual but get an error. " Error executing script for event: propertyChange on component: Password.

We are going to need to see your script and then the error in it's entirety.

Use the ``` to post your script and the exception so it'll read properly.

1 Like

The script on action event for the button is:

# Pull the username and password from the input components
uname = event.source.parent.getComponent("Username").text
pwd = event.source.parent.getComponent("Password").text
  
# Call switchUser. The event object is passed to this
# function so that if the username and password work,
# this window will be closed before the switch occurs.
success= system.security.switchUser(uname,pwd)
  
# If the login didn't work, give input focus back to the
# username component, so that the user can try again
if not success:
   event.source.parent.getComponent("Username").requestFocusInWindow()

The error is:

Traceback (most recent call last):
File "event:actionPerformed", line 2, in
AttributeError: 'com.inductiveautomation.factorypmi.application.com' object has no attribute 'text'

Nothing pops out by looking at it. Did you try using the property browser to get to the text properties of each component?

3 Likes

So, I did end up doing that and got a longer path and the error went away and now it works! Thank you! Follow up question to this. How would you "echo char" the characters in the password text field to cover up the password and close the pop up screen after a successful login?

Not completely sure I understand. Are you not using a password field?
image

5 Likes

Didn't see that component and that was way easier than I thought haha. Thank you

1 Like