How to check if user already exists before creating when user email is private?

I have the following user flow, I’m trying to figure out how to do 2a and 2b:

  1. User inputs email
  2. a. → If User with that email exits, show login form
    b. → If User with that email does not exist, create user
  3. Display a form to gather some simple information and save it to the user.

The problem with 2a is that the users email address is private data, so it isn’t searchable. If I made it public data, then I could search it, but that would also expose the users email address and make them vulnerable to spam scrapers, etc.

For 2a, I could also use “create an account for someone else” and check the “return the user if the account already exists” checkbox…

However, if I do that and the user doesn’t exist, then an account is created and the user is not logged in which means I can’t have the user complete step 3 since they’re not signed in and can’t save to the user.

All of this would be solved if I could figure out a way to check if an account already exists (by email) without publicly exposing the email.

You can take advantage of ability to handle errors to create this flow. Have a look below


This is great! But where did you find the error code in your example? You had to know the code was USED_EMAIL but what about if I need to catch other errors? I’m having trouble finding a list of errors in the documentation.

FYI… the error code in the example (and many others) can be found on the Settings >> Languages tab.

1 Like

Ah, thanks!

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.