Action for Pre User Registration

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!

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 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 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:

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

Thanks,
Rueben

1 Like

Thank you very much!

1 Like

Hi @friedman.ido,

Of course, you’re very welcome!

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