Auth0 Home Blog Docs

Prevent user from signing up if email already exists?

Basically I won’t to prevent the user from signing up if the email they are using to signup already exists in the any of the username/password database or any of the social connections. Basically, if that email exists already for any user, then they should be rejected.

Trying to figure this out with hooks, but can’t seem to find a way to query existing users across all connections?

Hello @harry4,

Welcome to the Community! If the email address matches and existing user profile in an Auth0 hosted database (and all such databases are enabled for the application in question), that will throw an error automatically, as email address is required to be unique**. If you are trying to do this across a number of Auth0 hosted databases, this could get complicated.

We (where I work) use a pre-reg hook to also check our old LDAP directory, to prevent new signups from using the username of an existing user. You should be able to do the same for social providers, but if you are using many such providers your hook is going to get complicated. You might want to use account linking instead.

**it used to be possible to create more than one user with the same email address, if you created then in quick succession. That may still be the case. Not likely to happen in the real world, but something to bear in mind if you are testing.