# Create rule to prevent social signup with GMAIL.COM but continue to support existing gmail users

**URL:** <https://community.auth0.com/t/create-rule-to-prevent-social-signup-with-gmail-com-but-continue-to-support-existing-gmail-users/107343>\
**Category:** Get Help\
**Tags:** signup-prompt-new-experience, login-experience\
**Created:** [May 19, 2023, 1:32am UTC](https://community.auth0.com/t/create-rule-to-prevent-social-signup-with-gmail-com-but-continue-to-support-existing-gmail-users/107343 "2023-05-19T01:32:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![deba](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/deba/32/47371_2.png) [@deba](https://community.auth0.com/u/deba)\
**Post date:** [May 19, 2023, 1:32am UTC](https://community.auth0.com/t/create-rule-to-prevent-social-signup-with-gmail-com-but-continue-to-support-existing-gmail-users/107343/1 "2023-05-19T01:32:55Z")

</div>

Hi there,

We would like to implement a rule that prevents a user with `@GMAIL.COM` email from signing up to our app using the Google social sign-up. We already have a rule that prevents it for the username/password signup.

The only caveat is that, we already have a bunch of users with `GMAIL.COM` accounts who are already registered in the product. We do not want to impact their experience and this should only impact the new users.

Thanks  
Deba

---

<div class="post-metadata">

**Author:** ![dawid.matuszczyk](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dawid.matuszczyk/32/74550_2.png) [@dawid.matuszczyk](https://community.auth0.com/u/dawid.matuszczyk)\
**Post date:** [June 30, 2023, 6:35pm UTC](https://community.auth0.com/t/create-rule-to-prevent-social-signup-with-gmail-com-but-continue-to-support-existing-gmail-users/107343/3 "2023-06-30T18:35:54Z")

</div>

Hi @deba

Welcome to the Auth0 Community!

First of all, sorry for the last response, I hope that I will be able to help you with your problem. I understand you would like to prevent new signups from the Google social connection when the user’s email address ends with `@GMAIL.COM`.

To achieve this functionality, you can use Auth0 Actions. Actions allow you to extend the functionality of Auth0 by running custom code during the authentication and authorization process. [Pre User Registration Flow](https://auth0.com/docs/customize/actions/flows-and-triggers/pre-user-registration-flow)

Your action will need to check before signup if the social connection is `google-oauth2` and if the username email ends with `@gmail.com`

Sample code:

```js
/**
 * @param {Event} event - Details about registration event.
 * @param {PreUserRegistrationAPI} api
 */
exports.onExecutePreUserRegistration = async (event, api) => {
const { email } = event.user.email;

  if (event.connection === 'google-oauth2' && email && email.endsWith('@gmail.com')) {
    return api.access.deny('Gmail sign-up is not allowed.');
  }

```

I hope it will help you!

Best regards  
Dawid

---

<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 14, 2023, 6:36pm UTC](https://community.auth0.com/t/create-rule-to-prevent-social-signup-with-gmail-com-but-continue-to-support-existing-gmail-users/107343/4 "2023-07-14T18:36:49Z")

</div>

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