# exports.onExecutePostLogin - event.organization null

**URL:** <https://community.auth0.com/t/exports-onexecutepostlogin-event-organization-null/106106>\
**Category:** Get Help\
**Tags:** login-experience, new-universal-login-experience\
**Created:** [May 3, 2023, 9:54pm UTC](https://community.auth0.com/t/exports-onexecutepostlogin-event-organization-null/106106 "2023-05-03T21:54:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dfleming](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dfleming/32/42432_2.png) [@dfleming](https://community.auth0.com/u/dfleming)\
**Post date:** [May 3, 2023, 9:54pm UTC](https://community.auth0.com/t/exports-onexecutepostlogin-event-organization-null/106106/1 "2023-05-03T21:54:15Z")

</div>

I have users in an organization. When I login as them exports.onExecutePostLogin executes but event.organization is always null. How can I fix this?

I see in this doc that its optional but I am unsure how to add it to event.

[Actions Triggers: post-login - Event Object (auth0.com)](https://auth0.com/docs/customize/actions/flows-and-triggers/login-flow/event-object)

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [May 3, 2023, 11:50pm UTC](https://community.auth0.com/t/exports-onexecutepostlogin-event-organization-null/106106/3 "2023-05-03T23:50:53Z")

</div>

Hi there @dfleming welcome to the community!

> [@dfleming](#):
>
> I see in this doc that its optional but I am unsure how to add it to event.

Do you mind sharing your action code so we can take a look?

I might also recommend taking a look at your token(s) at [jwt.io](http://jwt.io) - Do you see an `org_id` added as a claim? Here’s an example of what that would look like when a user is authenticated through an organization:

> **[Work with Tokens and Organizations](https://auth0.com/docs/manage-users/organizations/using-tokens#authenticate-users-through-an-organization)**
>
> Learn how tokens work with Auth0's Organizations feature and how to authenticate users belonging to an organization.

---

<div class="post-metadata">

**Author:** ![dfleming](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dfleming/32/42432_2.png) [@dfleming](https://community.auth0.com/u/dfleming)\
**Post date:** [May 8, 2023, 1:38pm UTC](https://community.auth0.com/t/exports-onexecutepostlogin-event-organization-null/106106/4 "2023-05-08T13:38:09Z")

</div>

I don’t want to authenticate a user through an organization because I won’t always know what organization the user is going to be in at the time of the redirect to `/authorize`.

I need to know their org during onExecutePostLogin (or using a rule `multifactorAuthentication`) so I can present them the MFA challenge based on their organization metadata.

Can I use the management API in a rule or action to look up a user’s org since event.organization is null?

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [May 10, 2023, 12:34am UTC](https://community.auth0.com/t/exports-onexecutepostlogin-event-organization-null/106106/5 "2023-05-10T00:34:01Z")

</div>

Gotcha, thanks for clarifying!

> [@dfleming](#):
>
> Can I use the management API in a rule or action to look up a user’s org since event.organization is null?

You could get the organizations a user belongs to using the Management API [/api/v2/users/{id}/organizations](https://auth0.com/docs/api/management/v2#!/Users/get_user_organizations). Some more on utilizing the Management API from within an action here:  
[https://community.auth0.com/t/how-can-i-use-the-management-api-in-actions/64947](https://community.auth0.com/t/how-can-i-use-the-management-api-in-actions/64947)

---

<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:** [May 26, 2023, 11:28pm UTC](https://community.auth0.com/t/exports-onexecutepostlogin-event-organization-null/106106/6 "2023-05-26T23:28:59Z")

</div>

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