system.security.switchUser

I am updating a vision project to perspective. That vision project has a button with this script on it:

# This script would go on a button in a popup window used to switch users without logging out of the client.
  
# 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,event,hideError=True)

if success:
	system.tag.write('[Client]user', uname)
	event.source.parent.getComponent('PasswordError').visible = False
	system.nav.closeParentWindow(event)
  
# 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()
	event.source.parent.getComponent('PasswordError').visible = True

Does the system.security.switchUser validate against the user/roles - user sources?

Perspective does not have equivalent functionality. You can navigate to a URL of a different project, but authentication cannot be forced.

Oh, hmm... anything remotely like that in perspective?

That's it.

LOL, thanks. Ill just have a text field that has to have a certain passcode in it to enable/disable a function

If that's the purpose, consider using Perspective's authentication challenge function--allows checking another user's credentials through the project IdP without actually switching users.

1 Like