Documentation for pre-user registration hooks

Hi,

I’m trying to make sense of the documentation for Pre-User Registration hooks at Pre-User Registration

I see there are code starters and examples for specific cases, but I didn’t find any documentation on how that fits within the registration process, or how the callback function affects the rest of the process.

All I see is that I can throw an error via the callback, which interrupts registration, and I also can specify a “response” with this callback but it’s not clear to me what this response is used for.

Is there some more comprehensive documentation that I’m missing?

Thanks

Hey there!

I would say this one:

is the core starter place to all things hooks that can help you grasp the idea of hooks. The one you referenced is a kind of specific for pre user registration aspect

Hi Konrad,

thanks for pointing me to the top-level documentation, but I’m afraid that doesn’t solve my doubts. Sorry if I wasn’t clear enough.

My question is mostly about the callback (“cb”) function that must be called from within a hook (specifically from a Pre-User Registration hook, in case that makes a difference). Ideally I’d like to see some documentation for that function: what do the parameters mean and how they affect the outcome of the registration process.

It’s a typical callback function:

@param {function} cb - Function (error, response)

Hi Konrad, thanks again for getting back to me.

I understand the concept of a callback function, but my question was if there’s any documentation for what this function does, or at least what data it expects.

As you can see, the second argument to the function is a “response” object. I assume I can use this argument to control some aspect of the application, but this doesn’t seem to be that well documented. I only see examples:

In one example, the response object has a “user” attribute, and there it says that “If you specify app_metadata and user_metadata in the response object, Auth0 adds this information to the new user.” So this bit is clear.

In another example, the response object also has a “context” attribute but there’s no explanation regarding that. The documentation does explain the “context” parameter to the hook function, but it doesn’t explain what’s the effect, if any, of adding a “context” attribute to the response object.

I was hoping for a clearer and more exhaustive documentation on how the response object can be used, instead of just one example for a specific use. If “adding this information to the new user” all that can be done with the response, or are there other possibilities?