# Post Login Authorization.Roles is Empty after Registration

**URL:** <https://community.auth0.com/t/post-login-authorization-roles-is-empty-after-registration/120238>\
**Category:** Get Help\
**Tags:** new-universal-login-experience, login-experience\
**Created:** [November 4, 2023, 10:28pm UTC](https://community.auth0.com/t/post-login-authorization-roles-is-empty-after-registration/120238 "2023-11-04T22:28:17Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![alelor01](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@alelor01](https://community.auth0.com/u/alelor01)\
**Post date:** [November 4, 2023, 10:28pm UTC](https://community.auth0.com/t/post-login-authorization-roles-is-empty-after-registration/120238/1 "2023-11-04T22:28:17Z")

</div>

I’ve created a Post-Registration Action to assign a default role to the user. This works as expected.

I’ve created a Post-Login Action to return this role in a custom claim. This works as expected when a user logs in.

However, the Post-Login Action does not work when registering. The event.authorization.roles object is empty, and so no roles are included in the custom claim.

I think this post is referring to the same issue but I can’t see a fix mentioned: [Why Post Login action is not called after Post Registration action?](https://community.auth0.com/t/why-post-login-action-is-not-called-after-post-registration-action/91436).

This post is also probably eluding to the same issue: [Why Post Login action is not called after Post Registration action?](https://community.auth0.com/t/why-post-login-action-is-not-called-after-post-registration-action/91436).

I contemplated combining the code like this post ([Post-login Action Not Assigning a Default Role on Login](https://community.auth0.com/t/post-login-action-not-assigning-a-default-role-on-login/118712)) but I setting the claims would probably require an extra API call, which I’d like to avoid. I could hardcode the role name but I would also like to avoid that.

Thanks,  
Alex

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [November 6, 2023, 6:46pm UTC](https://community.auth0.com/t/post-login-authorization-roles-is-empty-after-registration/120238/3 "2023-11-06T18:46:37Z")

</div>

Hi @alelor01,

> [@alelor01](#):
>
> I contemplated combining the code like this post ([Post-login Action Not Assigning a Default Role on Login](https://community.auth0.com/t/post-login-action-not-assigning-a-default-role-on-login/118712)) but I setting the claims would probably require an extra API call, which I’d like to avoid. I could hardcode the role name but I would also like to avoid that.

You should be able to use the solution provided in that FAQ you shared and append the roles as custom claims without incurring another API call. Unfortunately, this will require you to hardcode these Roles either directly in the Action script or as [Secrets](https://auth0.com/docs/customize/actions/write-your-first-action#add-a-secret).

Please let me know if you have any additional questions.

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![alelor01](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@alelor01](https://community.auth0.com/u/alelor01)\
**Post date:** [November 7, 2023, 8:19am UTC](https://community.auth0.com/t/post-login-authorization-roles-is-empty-after-registration/120238/4 "2023-11-07T08:19:32Z")

</div>

Hi Rueben,

Is there another way? Why is the Authorization.Roles array empty after registration has assigned a role? Is this expected?

Hardcoding the values adds an extra layer of work when I add future roles.

Alex

---

<div class="post-metadata">

**Author:** ![alelor01](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@alelor01](https://community.auth0.com/u/alelor01)\
**Post date:** [November 11, 2023, 8:25pm UTC](https://community.auth0.com/t/post-login-authorization-roles-is-empty-after-registration/120238/5 "2023-11-11T20:25:16Z")

</div>

Just to note - I do not consider Rueben’s answer to be the “solution”. Hardcoding values does not constitute an ideal solution, more a workaround.

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [November 13, 2023, 5:10pm UTC](https://community.auth0.com/t/post-login-authorization-roles-is-empty-after-registration/120238/6 "2023-11-13T17:10:56Z")

</div>

Hi @alelor01,

Thanks for your responses.

> [@alelor01](#):
>
> Is there another way? Why is the Authorization.Roles array empty after registration has assigned a role? Is this expected?

Yes, the other way is to use a Post-Login action to assign the user a role on the first login and append it as a custom claim.

Let me also clarify that the Post-Registration Action is **asynchronous** , while the Post-Login Action is **synchronous**. This means that the timing of when these actions complete are not synced in order. Therefore, you are experiencing a scenario where the Post-Login action is unaware of the updates performed on the user during the Post-User registration flow.

A workaround to hardcoding these values is to append them to the user\_metadata. This way you can still call `event.user.user_metadata` to retrieve the roles you need and proceed accordingly.

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [November 27, 2023, 5:11pm UTC](https://community.auth0.com/t/post-login-authorization-roles-is-empty-after-registration/120238/7 "2023-11-27T17:11:04Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
