0

We have Angular/Ionic app. One of the fields that we ask during registration is email. Then we save the data to the User collection.

We also check if the email is already used. Example query:

firestore
    .collection("User")
    .where("email", "==", email)
    .get()

The issue is that firebase is case-sensitive. For example, testemail@gmail.com and TESTemail@gmail.com will be considered as two different emails.

We have not lowercase an email during registration previously so this case-sensitive behavior potentially can cause issues. Any advice on how we can lowercase email in a request and in DB when checking if an email already exists?

slhn.dev
  • 313
  • 3
  • 8

1 Answers1

1

You have to update all the documents in your collection to either modify the existing email field value in such a way it is in lower case or keep the email field value as it is and create another field, e.g. emailLowerCase in which you save the value of the email field in lower case.

In other words, there is no way to adapt the query in such a way it returns the different variations of the email values.

Renaud Tarnec
  • 79,263
  • 10
  • 95
  • 121