Email Invitations for Multiple Applications

Hello, Auth0 community!

We are implementing email invitations for application signups following the solution provided in the thread Sending Email Invitations For Application Signup.

Our scenario includes two database connections, used with two distinct applications. The only difference from the provided answer is accessing the connection object for the connection name connection: context.connection.name.

The invites are sent from one of the applications.

module.exports = function (user, context, cb) {
  var auth0 = require('auth0@2.32.0');
  var authClient = new auth0.AuthenticationClient({
    domain: 'example-connections.us.auth0.com',
    clientId: 'YOUR_APP_CLIENT_ID',
    clientSecret: 'YOUR_APP_CLIENT_SECRET',
  });

  var userAndConnection = {
    email: user.email,
    connection: context.connection.name,
    connection_id: context.connection.id,
  };

  authClient.requestChangePasswordEmail(userAndConnection, function(err){
    cb(null, user, context);
  });
};

This works like a charm for one of the connections, but we don’t seem to receive any emails for the other.

We have logged the Hook functionality and confirmed that the connection name is correct.

Are there some other configurations we might have forgotten? :thinking:

Hi @Avb,

Welcome to the Auth0 Community!

Are you seeing any errors with this? Also, can you confirm the type of connection (auth0 database, google, facebook, etc.? Also please share the type of hook you are using.

Thanks for the reply, @dan.woda ,

We use two connections, both of type auth0 database, as well as a Post User Registration hook.

Further investigations in the logs revealed a Failed Change Password Request, with description “connection is disabled”.

We used the client ID of the wrong application, which is connected only to one of the connections. That’s what you get when naming the applications similar names :woozy_face:

We updated the client ID and things started working immediately :raised_hands:.

1 Like

Thanks for the update @Avb!

You certainly aren’t the first person to run into a mysterious issue that ends up as a typo!

I’m going to mark this resolved. Please feel free to open a new topic if you run into anything else!

1 Like