# Conditionally apply custom email validation in Lock

**URL:** <https://community.auth0.com/t/conditionally-apply-custom-email-validation-in-lock/97674>\
**Category:** Get Help\
**Tags:** classic-universal-login-experience, login-experience\
**Created:** [January 6, 2023, 10:06pm UTC](https://community.auth0.com/t/conditionally-apply-custom-email-validation-in-lock/97674 "2023-01-06T22:06:57Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![acrlq](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/acrlq/32/35392_2.png) [@acrlq](https://community.auth0.com/u/acrlq)\
**Post date:** [January 6, 2023, 10:06pm UTC](https://community.auth0.com/t/conditionally-apply-custom-email-validation-in-lock/97674/1 "2023-01-06T22:06:57Z")

</div>

Hi,

We’re using the classic universal login (w/ Lock) and need to conditionally apply restrictions to signup email domains (we’re conditionally applying this check based on values passed through to `config.extraParams`, which don’t appear to be available in Rules or Actions, so we can’t use those). There doesn’t appear to be any way to pause/cancel the authentication process from within the `"signup submit"` event handler, which we’d expect – even throwing an error there seems to have no effect. Is there something we’re missing? Or is there a way to provide a custom email validation function via the Lock options?

Thanks!

---

<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:** [January 6, 2023, 11:16pm UTC](https://community.auth0.com/t/conditionally-apply-custom-email-validation-in-lock/97674/3 "2023-01-06T23:16:01Z")

</div>

Hi @acrlq,

Thanks for reaching out to the Auth0 Community!

Firstly, I do not recommend using the `config.extraParams` as a method to conditionally apply restrictions to sign up since a user can simply bypass the restriction by omitting that query parameter. Moreover, there is no way to prevent sign-up in the HTML code.

In this case, I recommend using a Pre-User Registration action to prevent users from signing up if they do not meet your requirements for email validation.

I recommend checking out our [Users are registering with email domains that we don't want to allow](https://community.auth0.com/t/users-are-registering-with-email-domains-that-we-dont-want-to-allow/95744) FAQ as well.

Please let me know how this works for you.

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![acrlq](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/acrlq/32/35392_2.png) [@acrlq](https://community.auth0.com/u/acrlq)\
**Post date:** [January 6, 2023, 11:43pm UTC](https://community.auth0.com/t/conditionally-apply-custom-email-validation-in-lock/97674/4 "2023-01-06T23:43:55Z")

</div>

Hi @rueben.tiow Thanks for the reply. We do need to be able to conditionally restrict the email domains based upon parameters that we provide – specifically, we need to confirm that users are signing up with domains that match their intended use (corporate, personal, academic, etc) - how can we provide custom parameters to the pre-user reg action to know when to apply the checks? Without that, the actions are useless in this case.  
Thanks!

---

<div class="post-metadata">

**Author:** ![acrlq](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/acrlq/32/35392_2.png) [@acrlq](https://community.auth0.com/u/acrlq)\
**Post date:** [January 10, 2023, 5:18pm UTC](https://community.auth0.com/t/conditionally-apply-custom-email-validation-in-lock/97674/5 "2023-01-10T17:18:36Z")

</div>

Hi again @rueben.tiow is it possible to access `config.extraParams` from within the Rules or Actions functions?

---

<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:** [January 10, 2023, 6:39pm UTC](https://community.auth0.com/t/conditionally-apply-custom-email-validation-in-lock/97674/6 "2023-01-10T18:39:14Z")

</div>

Hi @acrlq,

Thank you for your responses.

> [@acrlq](#):
>
> is it possible to access `config.extraParams` from within the Rules or Actions functions?

Unfortunately, this is not possible, as you have discovered, and to reiterate, I would not recommend using the `config.extraParams` for this since an attacker could bypass any restrictions by omitting or passing the correct query parameter. Access control logic should never be determined by query parameters because it is a security risk.

Now, could you please provide an example of a condition that would pass and one that would fail based on the user’s email domain? I will try my best to see if I can offer a solution or workaround.

Thanks,  
Rueben

---

<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:** [January 24, 2023, 6:39pm UTC](https://community.auth0.com/t/conditionally-apply-custom-email-validation-in-lock/97674/7 "2023-01-24T18:39:36Z")

</div>

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