I have some users set up in custom roles and i would like for my application to bring you to certain pages based on the user who just logged in.
I seen a post regarding how to do this using the client event scripting but i discovered that is only available to vision whereas i am using perspective.
For example if an operator from the weather station was to log into to the application he does not need to see the other pages and should be directly brought to the weather page.
Thanks in advance for any tips or advice.
Add a change script to the user ID or username in the auth section of session properties. In that script, perform whatever check you need (probably roles?) to determine what page they should see is and then call system.perspective.navigate() to make the session switch to the determined page.
Rough-ish example code:
if currentValue.value != '':
pagePath = ''
roles = self.props.auth.user.roles
if 'RoleA' in roles:
pagePath = '/URL/To/Page/A'
elif 'RoleB' in roles:
pagePath = '/URL/To/Page/B'
system.perspective.navigate(pagePath)
Hey thank you, I tried this and it would not navigate me and the problem is not with the change script because i did some testing and it will successfully change a property it just doesnt navigate.
if currentValue.value != '':
roles = self.props.auth.user.roles
if 'Weather' in roles:
system.perspective.navigate('/weatherstation')
self.custom.joe = "hello"
pagePath = '/weatherstation'
elif 'Administrator' in roles:
system.perspective.navigate('/weatherstation')
self.custom.joe = "duffy"
pagePath = '/weatherstation'
system.perspective.navigate(pagePath)
I did try different variations of writing this out including yours this is what i done to desperately try getting to to navigate but it will not, also the line system.perspective.navigate(’/weatherstation’) works perfectly on a button.
I have no idea what im doing wrong
Ye it doesn’t appear to trigger actually, I did say above that the custom property changed but it only changed once or twice and now I believe it had nothing to do with the change script, I have still not found a solution to my problem.
Not for security really its just that different users will need to be looking at different pages, the application is kindof an overview different areas of a shipping port so a maintenance operator will be looking at ramps and pumps for example but someone logging in from the weather station should not see those things and should be directly brought to the weather portion.