# I can’t make the action execute after the user registration (passwordless)

**URL:** <https://community.auth0.com/t/i-can-t-make-the-action-execute-after-the-user-registration-passwordless/170065>\
**Category:** Get Help\
**Tags:** admin-management, dashboard\
**Created:** [January 24, 2025, 9:38am UTC](https://community.auth0.com/t/i-can-t-make-the-action-execute-after-the-user-registration-passwordless/170065 "2025-01-24T09:38:38Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![vlad5](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/vlad5/32/71442_2.png) [@vlad5](https://community.auth0.com/u/vlad5)\
**Post date:** [January 24, 2025, 9:38am UTC](https://community.auth0.com/t/i-can-t-make-the-action-execute-after-the-user-registration-passwordless/170065/1 "2025-01-24T09:38:38Z")

</div>

Hey here, i have some troubles creating an action.

I created an action:

```auto
// Updates user name on registration (converts user@gmail.com -> user)
exports.onExecutePostUserRegistration = async (event, api) => {
  if (!event.user.email) {
    return;
  }
  const name = event.user.email.split('@')[0];

  const ManagementClient = require('auth0').ManagementClient;
  const management = new ManagementClient({
    domain: event.secrets.AUTH0_DOMAIN,
    clientId: event.secrets.AUTH0_CLIENT_ID,
    clientSecret: event.secrets.AUTH0_CLIENT_SECRET,
  });

  await management.users.update({ id: event.user.user_id }, { name });
};

```

I clicked Deploy, tested it, and it works—it successfully changes the user’s name.

Then I assigned this action to the Post User Registration trigger and clicked Apply.

After that, I registered a new user on my website, went to the Auth0 console, and checked the user’s name. It still includes @gmail.com, meaning the action did not execute.

What could be the problem?

---

<div class="post-metadata">

**Author:** ![marybeth.hunter](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/marybeth.hunter/32/61955_2.png) [@marybeth.hunter](https://community.auth0.com/u/marybeth.hunter)\
**Post date:** [January 24, 2025, 3:12pm UTC](https://community.auth0.com/t/i-can-t-make-the-action-execute-after-the-user-registration-passwordless/170065/3 "2025-01-24T15:12:08Z")

</div>

Hi @vlad5,

Welcome to the Auth0 Community!

I couldn’t find this action in the tenant associated with your email address. Are you using another tenant?

In the tenant logs for this registration, do you see the `Actions Executions` tab? Does it show that it successfully ran? If it successfully running, I would then recommend using the [Real-time Webtask Logs Extension](https://auth0.com/docs/customize/extensions/real-time-webtask-logs) with some `console.log()` in the action code to further debug this issue.

Let me know!

Thanks,

Mary Beth

---

<div class="post-metadata">

**Author:** ![vlad5](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/vlad5/32/71442_2.png) [@vlad5](https://community.auth0.com/u/vlad5)\
**Post date:** [January 27, 2025, 5:28am UTC](https://community.auth0.com/t/i-can-t-make-the-action-execute-after-the-user-registration-passwordless/170065/4 "2025-01-27T05:28:24Z")

</div>

Hey @marybeth.hunter , thanks for your reply!

I found a log entry with the type “Failed Post User Registration Hook.”

My action:

```auto
// Updates user name on registration (converts user@gmail.com -> user)
exports.onExecutePostUserRegistration = async (event, api) => {
  if (!event.user.email) {
    return;
  }
  const name = event.user.email.split('@')[0];

  const ManagementClient = require('auth0').ManagementClient;
  const management = new ManagementClient({
    domain: event.secrets.AUTH0_DOMAIN,
    clientId: event.secrets.AUTH0_CLIENT_ID,
    clientSecret: event.secrets.AUTH0_CLIENT_SECRET,
  });

  console.log('Trying to update user ', event.user.user_id, ' with name: ', name);
  await management.users.update({ id: event.user.user_id }, { name });
};

```

The message itself looks like this:

```auto
{
  "action_name": "Update user name after registration",
  "response": {
    "error": {
      "message": "The user does not exist.",
      "name": "ManagementApiError",
      "stack": "ManagementApiError: The user does not exist.\n at UsersManager.parseError (/data/layers/us-west-2.amazonaws.com/_kuGEofdWh_nCW2RPj5wPxDfnOCLzXiSIH9QHw_s7u0=/node_modules/auth0/dist/cjs/management/management-client.js:33:16)\n at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n at async UsersManager.request (/data/layers/us-west-2.amazonaws.com/_kuGEofdWh_nCW2RPj5wPxDfnOCLzXiSIH9QHw_s7u0=/node_modules/auth0/dist/cjs/lib/runtime.js:119:23)\n at async UsersManager.update (/data/layers/us-west-2.amazonaws.com/_kuGEofdWh_nCW2RPj5wPxDfnOCLzXiSIH9QHw_s7u0=/node_modules/auth0/dist/cjs/management/__generated/managers/users-manager.js:561:26)\n at async exports.onExecutePostUserRegistration (/data/io/node22/c15f33fc-d656-4f7b-8dda-5d017d98ed0c/webtask.js:17:3)\n at async /data/io/a1d82dcbc495089dea716302768d597084946f7c.js:3:842"
    },
    "logs": "Trying to update user email|xyz with name: xyz_usr\n",
    "stats": {
      "action_duration_ms": 401
    }
  },
  "started_at": "2025-01-27T05:13:53.861Z",
  "ended_at": "2025-01-27T05:13:54.269969339Z"
}

```

If I go to the action, press the “Test” button, and set event.user.user\_id to “email|xyz” (the same value as in the log), the action executes successfully. When I navigate to this user in the Auth0 console, the user’s name is updated (e.g., “j+smith”).

However, according to the logs, at the time this action executes, the user cannot be found. Could there be any nuances in how the Post User Registration hook works?

 ![Screenshot 2025-01-27 at 12.29.13 PM](https://global.discourse-cdn.com/auth0/original/3X/a/a/aae980a94919294c937e4070ec80f6ccaf596195.png)

---

<div class="post-metadata">

**Author:** ![marybeth.hunter](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/marybeth.hunter/32/61955_2.png) [@marybeth.hunter](https://community.auth0.com/u/marybeth.hunter)\
**Post date:** [January 28, 2025, 4:52pm UTC](https://community.auth0.com/t/i-can-t-make-the-action-execute-after-the-user-registration-passwordless/170065/5 "2025-01-28T16:52:40Z")

</div>

Hi @vlad5,

Please see this article: [Update Made in Post-User Registration Action Not Available in Post-Login Action](https://community.auth0.com/t/update-made-in-post-user-registration-action-not-available-in-post-login-action/123120)

We recommend using a post-login action to perform updates to the user during an authentication transaction.

Can you try adding this login to a post-login action and see if it executes as expected?

Thanks,

Mary Beth

---

<div class="post-metadata">

**Author:** ![vlad5](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/vlad5/32/71442_2.png) [@vlad5](https://community.auth0.com/u/vlad5)\
**Post date:** [January 30, 2025, 9:46am UTC](https://community.auth0.com/t/i-can-t-make-the-action-execute-after-the-user-registration-passwordless/170065/6 "2025-01-30T09:46:04Z")

</div>

I added a post-login action that checks for the presence of a field in app\_metadata and adds a custom claim to the ID token. The rest of the logic I moved to my Node.js application.

---

<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 13, 2025, 9:46am UTC](https://community.auth0.com/t/i-can-t-make-the-action-execute-after-the-user-registration-passwordless/170065/7 "2025-02-13T09:46:21Z")

</div>

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