Hi,
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);
});
};