Pre User Registration not firing?

I added this pre registration hook to validate which users can registers and which cannot. Its an API request call.

The code works locally, and in the pre user registration simulator. But it’s not fired when a user tries to log in.

I deleted the user several times and tried with that one, but nothing happened. I also looked at the logs, expecting to find an entry for the hook, but there was nothing there either (maybe this entry does never happen)

Any suggestion?

@param {object} user - The user being created
@param {string} user.tenant - Auth0 tenant name
@param {string} user.username - user name
@param {string} user.password - user's password
@param {string} - email
@param {boolean} user.emailVerified - is e-mail verified?
@param {string} user.phoneNumber - phone number
@param {boolean} user.phoneNumberVerified - is phone number verified?
@param {object} context - Auth0 connection and other context info
@param {string} context.renderlanguage - language used by signup flow
@param {string} context.request.ip - ip address
@param {string} context.request.language - language of the client agent
@param {object} context.connection - information about the Auth0 connection
@param {object} - connection id
@param {object} - connection name
@param {object} context.connection.tenant - connection tenant
@param {object} context.webtask - webtask context
@param {function} cb - function (error, response)
const https = require('https');

module.exports = function (user, context, cb) {
  var response = {};

  response.user = user;
  const data = { email: };
  try {
    const postData = JSON.stringify(data);
    var options = {
      hostname: 'some.api',
      port: 443,
      path: '/authentication/validate',
      method: 'POST',
      headers: {
           'Content-Type': 'application/json',
           'Content-Length': postData.length
    var req = https.request(options, (res) => {
      console.log('statusCode:', res.statusCode);
      console.log('headers:', res.headers);
      res.on('data', (d) => {

      if (res.statusCode === 200) {
        cb(null, 'OK');
      } else {
        return cb('Error');
    req.on('error', (e) => {
  } catch (error) {
    return cb('Invalid User');

Hi @xavier.colomer.sopra,

Welcome to the Community!

These hooks only work with db users. Are you logging in with a social connection like google?

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.