# How to bail out of a Pre-registration Hook without an error

**URL:** <https://community.auth0.com/t/how-to-bail-out-of-a-pre-registration-hook-without-an-error/57744>\
**Category:** Get Help\
**Tags:** hooks\
**Created:** [February 11, 2021, 7:10pm UTC](https://community.auth0.com/t/how-to-bail-out-of-a-pre-registration-hook-without-an-error/57744 "2021-02-11T19:10:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jyi](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jyi/32/27548_2.png) [@jyi](https://community.auth0.com/u/jyi)\
**Post date:** [February 11, 2021, 7:10pm UTC](https://community.auth0.com/t/how-to-bail-out-of-a-pre-registration-hook-without-an-error/57744/1 "2021-02-11T19:10:51Z")

</div>

Hi,

I am trying to implement a user pre-registration hook in our passwordless login that will deny registration based on the results of a call to one of my servers.

To avoid exposing the results of the request to my server, I’d like to deny registration without an error response from /passwordless/start. My concern is that if /passwordless/start is conditionally returning error response based on my internal data, it is now vulnerable to phishing.

```
module.exports = function (user, context, cb) {
  var response = {};
  const canRegister = axios.get('myserver.com/validate')
  if (canRegister) {
      cb(null, response);
  } else {
      // bail out of registration process without error 
      cb(null, ?);
  }
};

```

Can pre-registration hook handle stopping the process without errors?

---

<div class="post-metadata">

**Author:** ![stephanie.chamblee](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/stephanie.chamblee/32/26087_2.png) [@stephanie.chamblee](https://community.auth0.com/u/stephanie.chamblee)\
**Post date:** [February 12, 2021, 9:00pm UTC](https://community.auth0.com/t/how-to-bail-out-of-a-pre-registration-hook-without-an-error/57744/3 "2021-02-12T21:00:51Z")

</div>

Hi @jyi,

Welcome to the Community!

Unfortunately, I don’t believe it is possible to prevent the 400 error or customize the response to the /passwordless/start endpoint.

The following will be returned when a pre-registration error is raised:

```auto
{
    "error": "extensibility_error",
    "error_description": "undefined"
}

```

The closest that you could achieve to this would be for the New Universal Login (but failing silently here would probably just be confusing):

```auto
module.exports = function (user, context, cb) {
  var response = {};
  const canRegister = axios.get('myserver.com/validate')
  if (canRegister) {
      cb(null, response);
  } else {
      // pass an empty string to not display an error in the new universal login
      return cb(new PreUserRegistrationError('')); 
  }
};

```

> **[Pre-User Registration](https://auth0.com/docs/customize/hooks/extensibility-points/pre-user-registration)**
>
> Learn how Hooks can be used with the Pre-User Registration extensibility point, which is available for database connections and passwordless connections.

It would be great to get your feedback about this in a feature request in our new Feedback category: [Feedback - Auth0 Community](https://community.auth0.com/c/feedback/95)

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [February 27, 2021, 9:01pm UTC](https://community.auth0.com/t/how-to-bail-out-of-a-pre-registration-hook-without-an-error/57744/4 "2021-02-27T21:01:36Z")

</div>

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