Hook code not working


I’ve written a pre-registration hook that does not seem to be triggering.

The code works fine when using the test runner. It also errors when creating a user via the Auth0 admin console (as expected as it is referencing firstname and lastname attributes that are not passed through the pipeline), but when registering via lock (which captures the additional attributes) it does not seem to trigger, there are no errors or call to the rest endpoint that the code makes.

Any help would be gratefully appreciated!

The code is:

module.exports = function (user, context, cb) {
request = require("request@2.56.0");

var options = {
 method: 'POST',
 url: 'https://emw1-cai.dm-em.informaticacloud.com/active-bpel/public/rt/1WPA8G9Fo8Cgp7iHgzzq8A/CRMCreateContact',
   headers: { 
    'Content-Type': 'application/json'
 body: {
      "Email": user.username,
      "FirstName": user.user_metadata.first_name,
      "LastName": user.user_metadata.last_name
 json: true

request(options, function (error, callresponse, body) {
 if (error) cb(new Error(error));
 var response = {};
    response.user = {
    user_metadata: {
            first_name: user.user_metadata.first_name,
            last_name: user.user_metadata.last_name,
            crmcontact: body.CRMContactUUID 
    cb(null, response);

Hi David. Not sure what the error that you are getting is, but you should be able to access a user’s user_metadata from a pre-registration hook. You can try this simpler version (to simplify the code and remove the possibility of the external request failing):

module.exports = function (user, context, cb) {
  // this will output the full user object, and you should
  // be able to see its `user_metadata` object populated
  var response = {};

  response.user = user;

  cb(null, response);

You can watch the console.log(user) output by running the Real-time Webtask Logs.

If you are still not seeing the data, you might want to try a cURL post directly to take Lock also out of the picture, with something like this:

curl -X POST \
  https://YOUR_AUTH0_DOMAIN/dbconnections/signup \
  -H 'Content-Type: application/json' \
  -H 'cache-control: no-cache' \
  -d '{
	"email" : "test789@test.com",
	"user_metadata":{"name": "john","color": "red"}

One final note, that might be obvious but could be easy to miss: remember to select the hook that you’ll want to use as the “active” one in the dropdown list (you can create multiple hooks but choose only one to run).

Hello, I’ve been trying to use pre-registration hook and it’s not working. No logs is being shown in live web task log. Even the simple example is not working. Is there any configurations besides creating the Hook? This is the error:

ExtensibilityLogicError on pre-user-registration: Unauthorized extensibility point.

Below is the code used:

module.exports = function (user, context, cb) {
  console.log('Will make the request');
  var response = {};
  response.user = user;
  const request = require('request@2.67.0');
  const options = {
    method: 'post',
    body: {
      user: user,
      context: context
    json: true,
    url: 'https://url/to/signup'
  request(options, function(err, httpResponse, body) {
    cb(err, err ? null : response);

The log output is:

12:10:40 AM: Connected
12:10:59 AM: new webtask request
12:10:59 AM: finished webtask request

The console.log output is not shown.

1 Like

Having the same problem with a very simple example.

Registration hooks currently only work with database connections. Is your app configured with a database connection, or another type of login?

Hi @Chipadeedoodah I’m using an app with database connection, and I have the same problem when I run me custom hook in the test console ran successfully, but then the hook not fired when I login into my app.

That definitely shouldn’t be happening, Kevin. If it’s persisting, please contact support.

1 Like

Thanks for reaching out here Chip!