# Restrict signup to invited emails only

**URL:** <https://community.auth0.com/t/restrict-signup-to-invited-emails-only/139300>\
**Category:** Get Help\
**Tags:** user-invitation, user-management\
**Created:** [July 19, 2024, 10:42am UTC](https://community.auth0.com/t/restrict-signup-to-invited-emails-only/139300 "2024-07-19T10:42:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![shachi](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@shachi](https://community.auth0.com/u/shachi)\
**Post date:** [July 19, 2024, 10:42am UTC](https://community.auth0.com/t/restrict-signup-to-invited-emails-only/139300/1 "2024-07-19T10:42:56Z")

</div>

I am using Auth0 for SSO to a white-labeled custom app (web and mobile). The app requires that the signup flow also be handled by the SSO provider, which I have set up.

The issue is that my app is private, so I want to allow signups only by email addresses that have been invited (invitations are sent directly from my CRM via Zapier through the custom app server).

**What’s the best way for me to restrict users from signing up with non-approved email addresses?**

**How can I restrict social logins at signup but allow them during log in?**

---

<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:** [July 22, 2024, 11:25pm UTC](https://community.auth0.com/t/restrict-signup-to-invited-emails-only/139300/3 "2024-07-22T23:25:14Z")

</div>

Hi @shachi,

Welcome to the Auth0 Community!

> [@shachi](#):
>
> **What’s the best way for me to restrict users from signing up with non-approved email addresses?**

The best way to block non-approved email addresses is to use a [Pre-User Registration Action](https://auth0.com/docs/customize/actions/flows-and-triggers/pre-user-registration-flow).

> [@shachi](#):
>
> How can I restrict social logins at signup but allow them during log in?

This one is trickier since social logins are triggered only in the post-login flow. The pre-user registration flow only runs before a user is added to a database or passwordless connection.

One way to handle this is to use a [post login action](https://auth0.com/docs/customize/actions/flows-and-triggers/login-flow) to block social logins when it is the user’s first time logging. This works because users automatically log in when they sign up.

Here’s an example of how you might implement this:

```auto
exports.onExecutePostLogin = async (event, api) => {
  if (event.stats.logins_count <= 1 && event.connection.strategy === event.connection.name){
    api.access.deny("access denied")
  }
};

```

This code will only allow users who have previously signed up using a social login to log in again.  
Let me know if you have any questions.

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:** [August 5, 2024, 11:26pm UTC](https://community.auth0.com/t/restrict-signup-to-invited-emails-only/139300/4 "2024-08-05T23:26:03Z")

</div>

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