# Return of users roles

**URL:** <https://community.auth0.com/t/return-of-users-roles/184288>\
**Category:** Get Help\
**Tags:** login-prompt-new-experience, login-experience\
**Created:** [March 21, 2025, 7:40pm UTC](https://community.auth0.com/t/return-of-users-roles/184288 "2025-03-21T19:40:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![badredine.haouari](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/badredine.haouari/32/73815_2.png) [@badredine.haouari](https://community.auth0.com/u/badredine.haouari)\
**Post date:** [March 21, 2025, 7:40pm UTC](https://community.auth0.com/t/return-of-users-roles/184288/1 "2025-03-21T19:40:56Z")

</div>

I have a question about user roles. When I create roles and assign a role to a user, I expect to retrieve a list of users using ‘event.authorization.roles’ in PostLogin. However, the array is always empty (), even though other details like username and metadata are returned correctly.

---

<div class="post-metadata">

**Author:** ![nik.baleca](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nik.baleca/32/68749_2.png) [@nik.baleca](https://community.auth0.com/u/nik.baleca)\
**Post date:** [March 21, 2025, 7:50pm UTC](https://community.auth0.com/t/return-of-users-roles/184288/3 "2025-03-21T19:50:03Z")

</div>

Hi @badredine.haouari

Welcome to the Auth0 Community!

If you have assigned roles to a user via the Auth0 Dashboard, they should be present in the `event.authorization.roles` parameter inside the `PostLogin Action`.

I have just tested this on my end with an user who has assigned roles using the `Real-Time Webtask Logs` extension available within the Auth0 and I was able to retrieve the user roles as seen below:

**USER ROLES**

 ![image](https://global.discourse-cdn.com/auth0/original/3X/3/d/3dff2cf42f5c8a795d7afa8d316ecc0db1516a19.png)

**ACTION CODE**

```auto
exports.onExecutePostLogin = async (event, api) => {

 console.log(event.authorization.roles)

}

```

**LOG OUTPUT**

![image](https://global.discourse-cdn.com/auth0/original/3X/e/b/eb7511e0d22baec2f7b94937736e241240a3411b.png)

If you have any other questions, let me know!

Kind Regards,  
Nik

---

<div class="post-metadata">

**Author:** ![badredine.haouari](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/badredine.haouari/32/73815_2.png) [@badredine.haouari](https://community.auth0.com/u/badredine.haouari)\
**Post date:** [March 21, 2025, 11:59pm UTC](https://community.auth0.com/t/return-of-users-roles/184288/4 "2025-03-21T23:59:50Z")

</div>

The problem is that despite assigning specific roles to the user, as shown in the figure above:

 ![image](https://global.discourse-cdn.com/auth0/original/3X/c/d/cde58bad15925b0ee7bd4bded5a2c8e739fe3141.png)

and I added the action trigger in PostLogin:

 ![image](https://global.discourse-cdn.com/auth0/original/3X/5/9/593a0421ad661226147e0be0518958b757849ad5.png)

the results is an empty array for roles every time:

 ![image](https://global.discourse-cdn.com/auth0/original/3X/f/0/f02083c17dcd3e424488dab6f79d264e5cb106b5.png)

---

<div class="post-metadata">

**Author:** ![nik.baleca](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nik.baleca/32/68749_2.png) [@nik.baleca](https://community.auth0.com/u/nik.baleca)\
**Post date:** [March 24, 2025, 4:32pm UTC](https://community.auth0.com/t/return-of-users-roles/184288/5 "2025-03-24T16:32:08Z")

</div>

Hi again @badredine.haouari

That is quite weird. The roles should definitely be available through `event.authorization.roles` as long as you have roles assigned through the dashboard.

I have used the same code you have posted inside the action and I was able to receive results in the console log and also the ID token of the user:

**ID TOKEN**

 ![image](https://global.discourse-cdn.com/auth0/original/3X/5/0/50a3416ac7f0ed5cd6070c36e7021e6000eba971.png)  
**CONSOLE LOG**  
 ![image](https://global.discourse-cdn.com/auth0/original/3X/a/3/a3f3d55c7818327e0f5c64b38b4440f95b5d82e8.png)  
**ACTION**  
 ![image](https://global.discourse-cdn.com/auth0/original/3X/b/6/b6fea6caa654cc775bb4fca8ffa9c975966afb47.png)

Could you try creating a test app and user and let me know if the ID token contains the claims set by the action?

Kind Regards,  
Nik
