# Custom Action. event.user.email is undefined

**URL:** <https://community.auth0.com/t/custom-action-event-user-email-is-undefined/125707>\
**Category:** Get Help\
**Tags:** other, missing-category\
**Created:** [January 25, 2024, 2:33pm UTC](https://community.auth0.com/t/custom-action-event-user-email-is-undefined/125707 "2024-01-25T14:33:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tom.fox](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@tom.fox](https://community.auth0.com/u/tom.fox)\
**Post date:** [January 25, 2024, 2:33pm UTC](https://community.auth0.com/t/custom-action-event-user-email-is-undefined/125707/1 "2024-01-25T14:33:52Z")

</div>

I’m adding a custom action to include the user email in the access token claims. Adding data to claims works fine. But for some reason the email property in the action event is undefined. Could it be related to the fact that the user hasn’t verified their email address?

exports.onExecutePostLogin = async (event, api) =\> {  
api.accessToken.setCustomClaim(“verified”, event.user.email\_verified) // false  
api.accessToken.setCustomClaim(“email”, event.user.email) // undefined  
};

---

<div class="post-metadata">

**Author:** ![tom.fox](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@tom.fox](https://community.auth0.com/u/tom.fox)\
**Post date:** [January 25, 2024, 10:23pm UTC](https://community.auth0.com/t/custom-action-event-user-email-is-undefined/125707/3 "2024-01-25T22:23:51Z")

</div>

Solved-ish: When attaching the event.user as “user” to the claims, the full user data shows up correctly in the resulting access token. But when specifying individual properties such as user.email. The result does not show up in the token. I am unsure why this is, but I am able to work with this approach

---

<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:** [January 27, 2024, 12:49am UTC](https://community.auth0.com/t/custom-action-event-user-email-is-undefined/125707/4 "2024-01-27T00:49:12Z")

</div>

Hey there @tom.fox welcome to the community!

Good to know you were able to find a valid workaround 🙂 If you’d like to include the `email` claim directly with `event.user.email` in access tokens I believe adding the `email` scope to however you are kicking off the `/authorize` request should do the trick. In auth0-react for example this would be in the `AuthorizationParams`:

> **[AuthorizationParams | @auth0/auth0-react](https://auth0.github.io/auth0-react/interfaces/AuthorizationParams.html#scope)**
>
> Documentation for @auth0/auth0-react

---

<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:** [February 10, 2024, 12:49am UTC](https://community.auth0.com/t/custom-action-event-user-email-is-undefined/125707/5 "2024-02-10T00:49:48Z")

</div>

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