# Passing custom parameters to pre-registration action from New Universal Login

**URL:** <https://community.auth0.com/t/passing-custom-parameters-to-pre-registration-action-from-new-universal-login/71594>\
**Category:** Get Help\
**Tags:** auth0\
**Created:** [October 19, 2021, 2:59pm UTC](https://community.auth0.com/t/passing-custom-parameters-to-pre-registration-action-from-new-universal-login/71594 "2021-10-19T14:59:24Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![sanjin.o](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/sanjin.o/32/32210_2.png) [@sanjin.o](https://community.auth0.com/u/sanjin.o)\
**Post date:** [October 19, 2021, 2:59pm UTC](https://community.auth0.com/t/passing-custom-parameters-to-pre-registration-action-from-new-universal-login/71594/1 "2021-10-19T14:59:24Z")

</div>

Hi all,

We are investigating pre-registration actions and we are using [GitHub - auth0/auth0-react: Auth0 SDK for React Single Page Applications (SPA)](https://github.com/auth0/auth0-react) library with “New Universal Login”.

Are we able to pass a custom parameter from to Auth0 sign-up page and forward it to the pre-registration action (after the user clicks on the sign-up button)?

We need those parameters only during the registration process. We need to use that parameter to determine if the user is eligible for registration or not by calling some external API from pre-registration action.

Our users are stored in the Auth0 database and we do not use social login, only registration with the user’s email address. Our Auth0 flow is Authorization Code Flow with PKCE.

Thank you very much in advance.  
Sanjin

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [October 19, 2021, 7:12pm UTC](https://community.auth0.com/t/passing-custom-parameters-to-pre-registration-action-from-new-universal-login/71594/3 "2021-10-19T19:12:12Z")

</div>

Hi @sanjin.o,

Thanks for reaching out to the Auth0 Community!

I understand that you’d like to know if you can pass a custom parameter from the sign-up page to a Pre-Registration Action to determine a user’s eligibility to sign up on your app.

Yes! This is possible. The custom parameters you pass to the `/authorize` request can be retrieved in the `event.request` property in the [Pre-Registration Action](https://auth0.com/docs/actions/triggers/pre-user-registration). See the [Event Object](https://auth0.com/docs/actions/triggers/pre-user-registration/event-object) for more properties.

Below is an example that denies access to a user conditionally on some custom parameter passed.

```auto
exports.onExecutePreUserRegistration = async (event, api) => {
  if (event.request.YOUR_PARAMETER === "SOMETHING") {
    api.access.deny(YOUR_REASON, YOUR_MESSAGE);
  }
};

```

Please let me know how this works for you.

Thank you.

---

<div class="post-metadata">

**Author:** ![sanjin.o](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/sanjin.o/32/32210_2.png) [@sanjin.o](https://community.auth0.com/u/sanjin.o)\
**Post date:** [October 20, 2021, 9:06am UTC](https://community.auth0.com/t/passing-custom-parameters-to-pre-registration-action-from-new-universal-login/71594/4 "2021-10-20T09:06:32Z")

</div>

Hi @rueben.tiow,

thank you for your reply.

Please explain to me how to call `/authorize` endpoint from [GitHub - auth0/auth0-react: Auth0 SDK for React Single Page Applications (SPA)](https://github.com/auth0/auth0-react) as there is only `loginWithRedirect(options)` available to call from `createAuth0Client` function.

 ![image](https://global.discourse-cdn.com/auth0/original/3X/c/6/c6faf75cb579383756977044e852853d7ade0aea.png).

Also, do we have to have a custom Login/Sign up Page which will hold custom parameter and pass it to Auth0 sign-up/registration endpoint ? If the custom login page is required, how to fetch custom parameter from the Auth0 React SDK ?

 ![image](https://global.discourse-cdn.com/auth0/original/3X/9/b/9bbb6c9c85117dfb58280dba246a5b2da5e195f6.png)

This is our desired flow:  
1.) Auth0 SDK sends “customParameter”  
2.) Auth0 Sign-up Page receives “customParameter” and forwards it to “Pre-Registration Action” where we can fetch it with the example which you have provided in “onExecutePreUserRegistration” function. If it is necessary.

Note: We are not using [Auth0 Management API](https://auth0.com/docs/api/management/v2) for sign-up or login process. We only want to use Auth0 React SDK.

Thank you very much in advance for your help.  
Sanjin

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [October 20, 2021, 7:50pm UTC](https://community.auth0.com/t/passing-custom-parameters-to-pre-registration-action-from-new-universal-login/71594/5 "2021-10-20T19:50:40Z")

</div>

Hi @sanjin.o,

Thank you for your response.

Let me take a step back and clarify a few things.

When calling the `loginWithRedirect(options)` function, you are inherently calling the `/authorize` endpoint. This endpoint is a reference to the Auth0 [Authentication API](https://auth0.com/docs/api/authentication#database-ad-ldap-passive-).

In essence, the Auth0 React SDK uses [Authorization Code flow with PKCE](https://auth0.com/docs/authorization/flows/authorization-code-flow-with-proof-key-for-code-exchange-pkce), which begins by calling the `/authorize` endpoint to exchange for an authorization code.

Now, circling back to your desired use-case, what you’ll need to do is to pass the _custom parameter_ to the `loginWithRedirect` function as you’ve done so, and it will be passed into the query URL.

Then you can use this parameter with the Pre-User Registration Action, to obtain that parameter to allow or deny access.

See below: I passed `person_1=true` as my custom parameter and it’s in the Request URL.

 ![Screen Shot 2021-10-20 at 12.34.15 PM](https://global.discourse-cdn.com/auth0/original/3X/c/b/cb1c011067f2df40c3b1d6a3ef506985e1dc72e8.jpeg)

 ![Screen Shot 2021-10-20 at 12.35.28 PM](https://global.discourse-cdn.com/auth0/original/3X/8/a/8ad329af3a002e43b761f30c492f26d4fae4470b.jpeg)

Then, from here, you can use the Pre-User Registration Action Script to get your custom parameter and allow/deny access to the user. The script will trigger after the user presses the **Sign Up** button.

Finally, I’d like to point out that the screenshots you have shared with me are consistent with the [Auth0-spa-js](https://github.com/auth0/auth0-spa-js) and not the [Auth0-react](https://github.com/auth0/auth0-react).

Regardless, the approach I offered will work with the Auth0-spa-js SDK.

Please let me know if you have any other questions. I’d be happy to clarify!

Thank you.

---

<div class="post-metadata">

**Author:** ![sanjin.o](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/sanjin.o/32/32210_2.png) [@sanjin.o](https://community.auth0.com/u/sanjin.o)\
**Post date:** [October 21, 2021, 2:53pm UTC](https://community.auth0.com/t/passing-custom-parameters-to-pre-registration-action-from-new-universal-login/71594/6 "2021-10-21T14:53:21Z")

</div>

Hi @rueben.tiow,

thank you for the explanation in your reply above.

1.) I’m able to see my custom parameter when the `/authorize` endpoint is called:

 ![image](https://global.discourse-cdn.com/auth0/original/3X/5/c/5c172a948df9e58d775366c1fd0298378834db7f.png)

2.) After clicking “Continue” button (screenshot below), I’m not able to find the custom parameter named “myCustomRegisterParam” in the Pre-User Registration action and object event.request. I have also console.logged the entire event.request object and observed it in monitoring logs (also in the Real-time Webtask Logs extension) but the custom parameter is not present in the event.request object.

 ![image](https://global.discourse-cdn.com/auth0/original/3X/7/6/767e5d483eabbb9802fa00b1218dff4b24833d32.png)

My Pre-User Registration action:

 ![image](https://global.discourse-cdn.com/auth0/original/3X/3/a/3a0f1b05df3be35204fb4f9dfa2b43c4e1750ea7.png)

Webtask log:

 ![image](https://global.discourse-cdn.com/auth0/original/3X/6/7/67216d3ff2cea27d6840406da07a75503bd07f6e.png)

I had some hooks and rules present in my Auth0 account and I have deleted them all just to be sure that something is not interrupting this process, but I had no luck.

What we can do next? Thank you very much in advance.  
Sanjin

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [October 21, 2021, 4:33pm UTC](https://community.auth0.com/t/passing-custom-parameters-to-pre-registration-action-from-new-universal-login/71594/7 "2021-10-21T16:33:45Z")

</div>

Hi @sanjin.o,

Thank you for your response and clarification.

After further testing, I found that the `event.request.query` parameters are only shown during Post-Login and never during Pre-User or Post-User Registration scripts.

Initially, I tested using the internal debugger in Actions and did not encounter this issue. That was because the test `event` request could be manipulated to my desire and always produced the results within the `event.request` object.

Since we are passing custom parameters to the URL, we need to be able to get the query parameters.

At this point, there does not seem to be a way to obtain these query parameters with the Pre-User Registration Hook. Meaning that you can only allow/deny access based only on the defined `event` object properties.

For now, I will reach out to our Engineers to see if there are any workarounds to make this work.

Once I receive new information, I will relay that to you.

Thank you.

---

<div class="post-metadata">

**Author:** ![sanjin.o](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/sanjin.o/32/32210_2.png) [@sanjin.o](https://community.auth0.com/u/sanjin.o)\
**Post date:** [October 25, 2021, 1:10pm UTC](https://community.auth0.com/t/passing-custom-parameters-to-pre-registration-action-from-new-universal-login/71594/8 "2021-10-25T13:10:30Z")

</div>

Hi @rueben.tiow,

thank you for your answer. Do you have any workaround or solution to make this work ?

Best regards,  
Sanjin

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [October 25, 2021, 8:39pm UTC](https://community.auth0.com/t/passing-custom-parameters-to-pre-registration-action-from-new-universal-login/71594/10 "2021-10-25T20:39:10Z")

</div>

Hi @sanjin.o,

Thank you for your response.

After collaborating with other Engineers, I confirmed that it is not possible to obtain the query parameters with the Pre-User Registration Action. Our Engineers also informed me that this could present the risk of the end-user manipulating the URL.

If applicable for a workaround, you could try using an invitation flow by sending an email inviting the user to register. The invitation will allow the user to set their password and gain access to your application. A user invitation is essentially a change password link repurposed as an invitation. You can learn more about this in our [Send Email Invitations for Application Signup](https://auth0.com/docs/brand-and-customize/email/send-email-invitations-for-application-signup) documentation.

Please let me know if this works for you. Otherwise, could you please provide more clarity on your intended flow on allowing/denying users to sign up?

Thank you.

---

<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:** [December 6, 2021, 11:48pm UTC](https://community.auth0.com/t/passing-custom-parameters-to-pre-registration-action-from-new-universal-login/71594/11 "2021-12-06T23:48:43Z")

</div>

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