Hook is not executed for all new signups

Hi @b.kisfali and @ross.arnott,

At the Post-User Registration extensibility point, Hooks allow custom actions to be executed after a new user registers an account and is added to the database.

The Post User Registration Hook will only run after a user signs up or is manually created for a database connection. This means that it will not run after a social connection sign up.

However, to catch all connection types, you can use a Rule instead.

Rules run after any successful authentication and can determine if it is the first time a user has authenticated.

For the rule, you can add this code at the top of the function so that it will only run for the user’s first authentication:

  var count = context.stats && context.stats.loginsCount ? context.stats.loginsCount : 0;
  if (count > 1) {
    return callback(null, user, context);
  }

Here is an example of using this approach to add a role upon the first authentication in a Rule:

1 Like