# Action for Pre User Registration

**URL:** <https://community.auth0.com/t/action-for-pre-user-registration/109483>\
**Category:** Get Help\
**Tags:** user-already-exists, user-management\
**Created:** [June 18, 2023, 7:11pm UTC](https://community.auth0.com/t/action-for-pre-user-registration/109483 "2023-06-18T19:11:51Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![friedman.ido](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/friedman.ido/32/48148_2.png) [@friedman.ido](https://community.auth0.com/u/friedman.ido)\
**Post date:** [June 18, 2023, 7:11pm UTC](https://community.auth0.com/t/action-for-pre-user-registration/109483/1 "2023-06-18T19:11:51Z")

</div>

Hey!

I have a problem that user can sign up with his google account and then sign up again with the same email (& password).

I need to create an action that blocks user from registration if the email exists (both ways - if exist in google dont let any email&password, and if exist in email&password dont let in google)

Can someone help me with creating this action?

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:** [June 19, 2023, 4:34pm UTC](https://community.auth0.com/t/action-for-pre-user-registration/109483/3 "2023-06-19T16:34:20Z")

</div>

Hi @friedman.ido,

Welcome to the Auth0 Community!

This will require two Action scripts to implement since a Pre User Registration Action only affects users who register through a Database or Passwordless connection.

First, in a Pre-User Registration Action, you will want to block users from signing up with a username and password if they exist in a Social Connection by calling the Management API’s [Search Users by email](https://auth0.com/docs/api/management/v2#!/Users_By_Email/get_users_by_email) endpoint. If the user is found, deny them from signing up.

Next, you will also need to create a Post Login Action script to block users from logging in with a Social Connection (Google in this case) if they exist in a Username-Password database connection by calling the Management API’s [Search Users by email](https://auth0.com/docs/api/management/v2#!/Users_By_Email/get_users_by_email) endpoint.

Recall that we cannot use a Pre-User Registration Action with Social Connections, therefore, we recommend using a Post-Login Action to check if it’s the Social Connection user’s first time logging in. If so, we can conclude that they are signing up and proceed with our blocking logic. However, please note that this will still create a Social Connection user but prevent them from logging in.

I have shared some resources below that will help with the implementation:

- [How can I use the Management API in Actions?](https://community.auth0.com/t/how-can-i-use-the-management-api-in-actions/64947)
- [Pre User Registration Flow](https://auth0.com/docs/customize/actions/flows-and-triggers/pre-user-registration-flow)
- [Login Flow](https://auth0.com/docs/customize/actions/flows-and-triggers/login-flow)

Please let me know how this goes for you or if you need additional help with the implementation.

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![friedman.ido](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/friedman.ido/32/48148_2.png) [@friedman.ido](https://community.auth0.com/u/friedman.ido)\
**Post date:** [June 21, 2023, 4:46pm UTC](https://community.auth0.com/t/action-for-pre-user-registration/109483/4 "2023-06-21T16:46:07Z")

</div>

Thank you very much!

---

<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:** [June 21, 2023, 6:21pm UTC](https://community.auth0.com/t/action-for-pre-user-registration/109483/5 "2023-06-21T18:21:35Z")

</div>

Hi @friedman.ido,

Of course, you’re very welcome!

---

<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:** [July 5, 2023, 6:22pm UTC](https://community.auth0.com/t/action-for-pre-user-registration/109483/6 "2023-07-05T18:22:15Z")

</div>

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