Auth0 password change with actions

Hello,

I found a solution for the problem, but it is for hooks (Sending password change email instead of verification email for a new user - #3 by stephanie.chamblee).
Is there one for actions?

I adjusted the hook code to the actions version but get the following error messag:

Test Results
Error:
{
  "message": "authClient.requestChangePasswordEmail is not a function",
  "name": "TypeError",
  "stack": "TypeError: authClient.requestChangePasswordEmail is not a function\n    at exports.onExecutePostUserRegistration (/data/io/node18-actions/eb0226ed-9d75-4aab-938f-39324a6ea7de/webtask.js:20:14)\n    at /data/io/0c8366ec199636bd5aa9715551a2d91fb6316755.js:7:907\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)"
}

Kind regards,

David Bos

I am experiencing the same issue with what should be very basic code. What are we missing???

exports.onExecutePostLogin = async (event) => {
if (event.user.email !== undefined) {
    const auth0 = require('auth0');
    const authClient = new auth0.AuthenticationClient({
      domain: event.secrets.domain,
      clientId: event.secrets.clientId
    });

  const userAndConnection = {
      email: event.user.email,
      connection: 'Username-Password-Authentication'
    };

  // Send password change email
    await authClient.requestChangePasswordEmail(userAndConnection, (err) => {
      
      })
  }
};
      

Hello there,

I am facing the exact same issue and did not find a solution to this so far. @simon.paris or @adminiot were you able to figure this out?

Any help would be highly appreciated!

Hey there!

As this topic is related to Actions and Rules & Hooks are being deprecated soon in favor of Actions, I’m excited to let you know about our next Ask me Anything session in the Forum on Thursday, January 18 with the Rules, Hooks and Actions team on Rules & Hooks and why Actions matter! Submit your questions in the thread above and our esteemed product experts will provide written answers on January 18. Find out more about Rules & Hooks and why Actions matter! Can’t wait to see you there!

Learn more here!

@konrad.sopala - not helpful. This response is getting pushed into every Actions-related thread, but doing nothing to answer any of the questions posted in your community. This is quickly diluting the usefulness of these forums.

As communicated, in the community thread above, once you post there your question it will be answered on January 18th. Thank you!

We solved it like this:

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

    var axios = require("axios").default;

    var options = {
        method: 'POST',
        url: 'https://' + event.secrets.DOMAIN + '/dbconnections/change_password',
        headers: {
            'content-type': 'application/json'
        },
        data: {
            client_id: event.secrets.CLIENT_ID,
            email: event.user.email,
            connection: 'Username-Password-Authentication'
        }
    };

    axios.request(options).then(function (response) {
        console.log(response.data);
    }).catch(function (error) {
        console.error(error);
    });
};```

And disabled the verification email.

@adminiot If you don’t mind I will attach Stackoverflow Thread as well here. Full answer can approach via this link → node.js - How to send password change email instead of verification email for a new user in Auth0 in 2024 - Stack Overflow

1 Like