# Getting current user roles onStartup session

**URL:** <https://forum.inductiveautomation.com/t/getting-current-user-roles-onstartup-session/43636>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [February 19, 2021, 8:51pm UTC](https://forum.inductiveautomation.com/t/getting-current-user-roles-onstartup-session/43636 "2021-02-19T20:51:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![drojas](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/drojas/32/3403_2.png) [@drojas](https://forum.inductiveautomation.com/u/drojas)\
**Post date:** [February 19, 2021, 8:51pm UTC](https://forum.inductiveautomation.com/t/getting-current-user-roles-onstartup-session/43636/1 "2021-02-19T20:51:57Z")

</div>

I am trying to populate a dropdown menu of all the roles that the current user belongs to after they have logged in to a Perspective session (using an internal usersource and Ignition default IdP). However, the system.security.getRoles() function isn’t working. If I try to use system.user.getRoles(‘someUserSource’) instead, this does work and returns all the roles for the user source, so I know my dropdown works. And using system.security.getUserRoles(‘hardcodedusername’,‘hardcodedpassword’,‘someUserSource’) also works. But I obviously can’t use that function since I don’t know what the password is for the user. I don’t even understand why this function requires the password if the password shouldn’t be known to anyone, not even the programmer.  
Anyways, does anyone know what’s going on?

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/9/495c137bb98b84b33ad7aae71e69c07c29ccabeb.png)

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [February 19, 2021, 9:06pm UTC](https://forum.inductiveautomation.com/t/getting-current-user-roles-onstartup-session/43636/2 "2021-02-19T21:06:31Z")

</div>

I think it has to do with script scope? The user manual shows

```auto
system.security.getRoles() has vision client scope
 
system.user.getRoles() has gateway and vision client scope.  

```

---

<div class="post-metadata">

**Author:** ![drojas](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/drojas/32/3403_2.png) [@drojas](https://forum.inductiveautomation.com/u/drojas)\
**Post date:** [February 19, 2021, 9:09pm UTC](https://forum.inductiveautomation.com/t/getting-current-user-roles-onstartup-session/43636/3 "2021-02-19T21:09:54Z")

</div>

Completely forgot about scopes. Thanks for reminding me. However, I still can’t get anything to work to pull in the current user’s roles in Perspective. The session object has the roles under session.auth.user.roles, but it also doesn’t function properly.

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [February 19, 2021, 9:11pm UTC](https://forum.inductiveautomation.com/t/getting-current-user-roles-onstartup-session/43636/4 "2021-02-19T21:11:51Z")

</div>

You should actually be looking at the user object in the session properties; this removes the need to call out to the Gateway:  
 ![Screen Shot 2021-02-19 at 1.10.38PM](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/7/b7a9274ef347c19bcd1150a985670beef810ae4a.png)

> [@drojas](#):
>
> but it also doesn’t function properly.

How so?

---

<div class="post-metadata">

**Author:** ![drojas](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/drojas/32/3403_2.png) [@drojas](https://forum.inductiveautomation.com/u/drojas)\
**Post date:** [February 19, 2021, 9:15pm UTC](https://forum.inductiveautomation.com/t/getting-current-user-roles-onstartup-session/43636/5 "2021-02-19T21:15:14Z")

</div>

I forgot to type the “.props.” part. it is session.props.auth.user…I had tried session.auth.user…which didn’t work. Thanks. Growing pains of officially developing on Perspective for the first time
