# Post Password Change Action is failing | api coming in nil

**URL:** <https://community.auth0.com/t/post-password-change-action-is-failing-api-coming-in-nil/182401>\
**Category:** Get Help\
**Tags:** users, management-api\
**Created:** [February 19, 2025, 12:40am UTC](https://community.auth0.com/t/post-password-change-action-is-failing-api-coming-in-nil/182401 "2025-02-19T00:40:25Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![dwood1](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dwood1/32/60033_2.png) [@dwood1](https://community.auth0.com/u/dwood1)\
**Post date:** [February 19, 2025, 12:40am UTC](https://community.auth0.com/t/post-password-change-action-is-failing-api-coming-in-nil/182401/1 "2025-02-19T00:40:25Z")

</div>

We’re currently in full swing of an updating our test env to handle the latest v4 changes with our actions. We of course, came across some methods that began to fail and proceeded to update the logic. Currently, I am unable to update the user\_metadata as a result of the api returning a nil object when the post password change action is run. Please review the action below, to ensure that we all know what is taking place.

```auto
  "date": "2025-02-19T00:23:56.342Z",
  "type": "fcph",
  "description": "TypeError on post-change-password: Cannot read properties of undefined (reading 'sendUserTo')",
  "connection": "our-connection-to-database",

```

* * *

```auto
const axios = require("axios");
const ManagementClient = require('auth0').ManagementClient;

exports.onExecutePostChangePassword = async (event, api) => {

  if(event.request.method === 'PUT'){
    return;
  }

  const managementClient = new ManagementClient({
        clientId: event.secrets.CLIENT_ID,
        clientSecret: event.secrets.CLIENT_SECRET,
        domain: event.secrets.DOMAIN,
        scope: 'create:user_tickets',
      });
  const params = { id : event.user.user_id};
  const data = { "user_metadata":{"id": event.user.user_id, "force_password_change": null, "last_password_reset": null}};

  try {
    const res = await managementClient.users.update(params, data)
  } catch (e) {
    console.log(e)
  }
 api.redirect.sendUserTo(`https://${event.secrets.AUTH0_CUSTOM_DOMAIN}/v2/logout?returnTo=https://${event.secrets.HIDDEN_DOMAIN}/?state=pw_reset`);
};

```

---

<div class="post-metadata">

**Author:** ![dwood1](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dwood1/32/60033_2.png) [@dwood1](https://community.auth0.com/u/dwood1)\
**Post date:** [February 19, 2025, 2:45am UTC](https://community.auth0.com/t/post-password-change-action-is-failing-api-coming-in-nil/182401/3 "2025-02-19T02:45:21Z")

</div>

Last note, I modified the scope to add update:users/update:current\_user\_metadata – yet the test user while the simulation runs – is coming back as not found.  
`ManagementApiError: The user does not exist.`

---

<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:** [February 19, 2025, 2:47am UTC](https://community.auth0.com/t/post-password-change-action-is-failing-api-coming-in-nil/182401/4 "2025-02-19T02:47:52Z")

</div>

Hi @dwood1,

The error indicates that you used an invalid method, particularly when calling `api.redirect.sendUserTo()`.

I have checked our [Actions Triggers: post-change-password - API Object](https://auth0.com/docs/customize/actions/explore-triggers/password-reset-triggers/post-change-password-trigger/post-change-password-api-object) documentation and confirmed that there isn’t a redirect method available.

This is only available in the `onExecutePostChallenge` trigger.

If you would like the user to be redirected to a specific URL after they have reset their password, you can set that value in your Change Password (link) email template under the "Redirect To’ field.

For more details, I recommend referring to our [Password Change Redirect Behavior](https://community.auth0.com/t/password-change-redirect-behavior/94239) knowledge solution.

Cheers,  
Rueben

---

<div class="post-metadata">

**Author:** ![dwood1](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dwood1/32/60033_2.png) [@dwood1](https://community.auth0.com/u/dwood1)\
**Post date:** [February 19, 2025, 2:01pm UTC](https://community.auth0.com/t/post-password-change-action-is-failing-api-coming-in-nil/182401/5 "2025-02-19T14:01:26Z")

</div>

After moving the redirect logic – it is in fact working. Thank you.

---

<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:** [February 19, 2025, 6:46pm UTC](https://community.auth0.com/t/post-password-change-action-is-failing-api-coming-in-nil/182401/6 "2025-02-19T18:46:47Z")

</div>

Hi @dwood1,

I’m glad the redirect logic is working now.

Let us know if there’s anything else we can do to help!

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:** [March 5, 2025, 6:47pm UTC](https://community.auth0.com/t/post-password-change-action-is-failing-api-coming-in-nil/182401/7 "2025-03-05T18:47:27Z")

</div>

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