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.
"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",
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`);
};