# Is it possible to override user attributes in a post-login action?

**URL:** <https://community.auth0.com/t/is-it-possible-to-override-user-attributes-in-a-post-login-action/130258>\
**Category:** Get Help\
**Tags:** login-experience, new-universal-login-experience\
**Created:** [March 22, 2024, 3:43pm UTC](https://community.auth0.com/t/is-it-possible-to-override-user-attributes-in-a-post-login-action/130258 "2024-03-22T15:43:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jrosen-cc](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jrosen-cc/32/52434_2.png) [@jrosen-cc](https://community.auth0.com/u/jrosen-cc)\
**Post date:** [March 22, 2024, 3:43pm UTC](https://community.auth0.com/t/is-it-possible-to-override-user-attributes-in-a-post-login-action/130258/1 "2024-03-22T15:43:40Z")

</div>

### Use-Case

Auth0 contains personally-identifiable information (PII) that we don’t want to share with a particular application. We _do_ want the user to be able to log in to the application and get a valid session. I _don’t_ want to change the actual data in Auth0, just the presentation to this client application.

Is it possible to override the PII fields on the token during the post-login flow?

I’m imagining something like

```ts
exports.onExecutePostLogin = async (event, api) => {
  const { user_id: id } = event.user
  api.user.setEmail(`${id}@example.com`);
  api.user.setName(`Anonymous User ${id}`)
  api.user.setNickname(`Anonymous`)
};

```

These APIs don’t actually exist. Is there something else that would accomplish this?

Possibly related: [Actions: How do I \*set\* an event.user.nickname?](https://community.auth0.com/t/actions-how-do-i-set-an-event-user-nickname/118266)

---

<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:** [March 22, 2024, 5:05pm UTC](https://community.auth0.com/t/is-it-possible-to-override-user-attributes-in-a-post-login-action/130258/3 "2024-03-22T17:05:17Z")

</div>

Hi @jrosen-cc,

Yes, you should be able to override the user attributes without permanently updating them.

Here is an example:

```auto
exports.onExecutePostLogin = async (event, api) => {
  const { user_id: id } = event.user
  event.user.email = `${id}@example.com`
  event.user.name = `Anonymous User ${id}`
  event.user.nickname = `Anonymous`
};

```

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![jrosen-cc](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jrosen-cc/32/52434_2.png) [@jrosen-cc](https://community.auth0.com/u/jrosen-cc)\
**Post date:** [March 22, 2024, 5:18pm UTC](https://community.auth0.com/t/is-it-possible-to-override-user-attributes-in-a-post-login-action/130258/4 "2024-03-22T17:18:31Z")

</div>

This is very helpful. Thank you!

It’s not clear from any of the examples on the website that `event` is mutable or that mutations will be carried through the rest of the process.

---

<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:** [March 22, 2024, 6:20pm UTC](https://community.auth0.com/t/is-it-possible-to-override-user-attributes-in-a-post-login-action/130258/5 "2024-03-22T18:20:31Z")

</div>

Hi @jrosen-cc,

You’re welcome!

Yes, that’s true. I will add that it’s usually only used in cases where you need to map user\_metadata/app\_metadata into claims in the SAML Response.

Feel free to reach out again if you’ve got more questions!

Cheers,  
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:** [April 5, 2024, 6:21pm UTC](https://community.auth0.com/t/is-it-possible-to-override-user-attributes-in-a-post-login-action/130258/6 "2024-04-05T18:21:26Z")

</div>

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