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

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: https://community.auth0.com/t/invite-only-flow-using-hook/11179/2

Let me know if you have any trouble!

Stephanie

1 Like