Switching user with perspective

Hello I am wondering is there a script to switch users that will work with perspective?

1 Like

Hi @sebastian.zanotto -

You can call call system.perspective.logout which will log the current user out. You can then call system.perspective.login to redirect them to the IdP to login as a new user.


I tried to do the method you mentioned above but haven’t had any luck getting it to work.

when I try to call both functions, the screen refreshes and doesn’t log the user out. If I manually logout, then the button will redirect to a login screen. It’s as though only the login function is called before the logout function gets the chance to execute. I’ve tried making this work as a Logout action followed by a Login action, as well as a single script that calls both system.perspective.logout followed by system.perspective.login.

Thanks for any help

I’m assuming your project requires authentication? In this case, isn’t it enough to simply log the user out? The next user will be on the Sign In screen, and they can click the button to login to the IdP.

I would not call the logout and login scripts or actions back to back (in one script or one action sequence) since the process of logging in or out will navigate the user away from the Perspective page and to the IdP. 8.0.10-RC has a fix which prevents any login and logout attempts from happening on the current page once a single login or logout attempt has been invoked. This should prevent the issue you are seeing with the login “overwriting” the logout attempt that was made before it.

Thanks for the quick reply.

Just logging out would likely be enough, but this is a project where we are upgrading a vision project to perspective and want as close to 1 to 1 as possible for the lowest amount of friction for the user. The previous just uses a popup window with a system.security.switchUser call.

Sure, that makes sense. User authentication is one of those areas where Vision and Perspective start to diverge. There is no way to do exactly what system.security.switchUser does in Perspective right now. It’s possible that we can devise a good pattern for this from lessons learned once we really start digging into making Vision IdP-enabled.