# Redirecting based on logged in user

**URL:** <https://forum.inductiveautomation.com/t/redirecting-based-on-logged-in-user/58687>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [April 21, 2022, 1:12pm UTC](https://forum.inductiveautomation.com/t/redirecting-based-on-logged-in-user/58687 "2022-04-21T13:12:28Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dean\_Walsh](https://avatars.discourse-cdn.com/v4/letter/d/8797f3/32.png) [@Dean\_Walsh](https://forum.inductiveautomation.com/u/Dean_Walsh)\
**Post date:** [April 21, 2022, 1:12pm UTC](https://forum.inductiveautomation.com/t/redirecting-based-on-logged-in-user/58687/1 "2022-04-21T13:12:28Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [April 21, 2022, 6:46pm UTC](https://forum.inductiveautomation.com/t/redirecting-based-on-logged-in-user/58687/2 "2022-04-21T18:46:20Z")

</div>

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:

```auto
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)

```

---

<div class="post-metadata">

**Author:** ![Dean\_Walsh](https://avatars.discourse-cdn.com/v4/letter/d/8797f3/32.png) [@Dean\_Walsh](https://forum.inductiveautomation.com/u/Dean_Walsh)\
**Post date:** [April 22, 2022, 2:50pm UTC](https://forum.inductiveautomation.com/t/redirecting-based-on-logged-in-user/58687/3 "2022-04-22T14:50:09Z")

</div>

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.

```auto
	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

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [April 25, 2022, 1:38pm UTC](https://forum.inductiveautomation.com/t/redirecting-based-on-logged-in-user/58687/4 "2022-04-25T13:38:42Z")

</div>

im not sure onchange scripts in the sessions props trigger for the user during login.

---

<div class="post-metadata">

**Author:** ![Dean\_Walsh](https://avatars.discourse-cdn.com/v4/letter/d/8797f3/32.png) [@Dean\_Walsh](https://forum.inductiveautomation.com/u/Dean_Walsh)\
**Post date:** [April 25, 2022, 1:43pm UTC](https://forum.inductiveautomation.com/t/redirecting-based-on-logged-in-user/58687/5 "2022-04-25T13:43:56Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [April 25, 2022, 1:51pm UTC](https://forum.inductiveautomation.com/t/redirecting-based-on-logged-in-user/58687/6 "2022-04-25T13:51:12Z")

</div>

> [@Dean\_Walsh](#):
>
> not need to see the other pages

Is this for security? because that would be poor security. You need to add security to the views itself too.

There are session event scripts for perspective too tho, but i doubt it will work aswell.

Edit yeah it wont work:

> [@Perspective - navigate on startup](https://forum.inductiveautomation.com/t/perspective-navigate-on-startup/26064):
>
> Hello! I’m trying to use system.perspective.navigate on a Session Startup event. Essentially I’m looking at specific attributes of the user and letting them either pass through to the main view or directing them to an option select view. onlyPlants = ['Plant 1','Plant 2','Plant 3'] session.custom.plantSelect.plantList = onlyPlants if len(onlyPlants) == 1: session.custom.plantSelect.plantNumber = onlyPlants[0] else: session.custom.plantSelect.plantNum…

---

<div class="post-metadata">

**Author:** ![Dean\_Walsh](https://avatars.discourse-cdn.com/v4/letter/d/8797f3/32.png) [@Dean\_Walsh](https://forum.inductiveautomation.com/u/Dean_Walsh)\
**Post date:** [April 25, 2022, 3:12pm UTC](https://forum.inductiveautomation.com/t/redirecting-based-on-logged-in-user/58687/7 "2022-04-25T15:12:23Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Maryam\_Saeed](https://avatars.discourse-cdn.com/v4/letter/m/a5b964/32.png) [@Maryam\_Saeed](https://forum.inductiveautomation.com/u/Maryam_Saeed)\
**Post date:** [March 14, 2025, 5:00am UTC](https://forum.inductiveautomation.com/t/redirecting-based-on-logged-in-user/58687/8 "2025-03-14T05:00:07Z")

</div>

Any updated on this? I am trying to do the same thing. It won't navigate to a page
