Sending password change email instead of verification email for a new user

Hello!!!

I am new to Auth0 and I am working on integrating the Auth0 with my NodeJS app. I have checked the quick start and came to know how to setup Auth0 with my NodeJS app and also I came to know how to create API in Auth0 and integrate with my App.

Now my doubt is whenever I add a new user under user management in Auth0, a verification email is sent to the user but instead of the verification email I want the user to get password change email is this possible to achieve ?

Since I am new to Auth0 is there a way for me to find step by step process to achieve it.

Hi @vignesh.ramesh,

Here is an approach you could take to send a password reset email instead of email verification when adding users :

1. Disable the verification email template

Go to Emails > Email Templates in your Auth0 dashboard. Toggle off Status on the Verification Email template

2. Create a Hook to send the reset password email on Post User Registration

Go to Hooks in your Auth0 dashboard. Click the “+ CREATE A HOOK” button. Give the hook a name, select “Post User Registration” from the drop down, and click “Create”.

Click on the pencil icon to edit your new hook.

Add auth0 as an NPM module by clicking on the wrench icon on the top left of the editor:

And paste this code into the editor (update the domain and Client ID):

module.exports = function (user, context, cb) {
  const auth0 = require('auth0');
  const authClient = new auth0.AuthenticationClient({
    domain: '', // Add your domain here (you can find your domain from your application settings)
    clientId: '' // Add your app's Client ID here (you can find the Client ID from your application settings)
  });

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

  authClient.requestChangePasswordEmail(userAndConnection, () => {
  cb(null, user, context);
  });
};

Here’s a related topic as well: Invite Only Flow using Hook

Let me know if you have any trouble!

Stephanie

1 Like

Hello Stephanie!!!

Thanks for providing me the solution. I works fine completely.

2 Likes

That’s great to hear it is working for you!

1 Like

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