Is it Possible? sending email verification before a record is created in firebase authentication?

Viewed 278

Is it Possible? can I send email verification before I create a user with email and password in Firebase authentication using flutter? I wanted to know this because if I register the entered mail and then if I send email verification, then if the email account is not valid(i.e the email format is correct, but it is not present in google database to send link to email), then it would simply create a record in Firebase authentication which is a loss of storage, so I would like to know. Thank you

2 Answers

There are two providers for signing in with email to Firebase:

  1. Through Email+password. There is no way to require the user to verify their email address before they can sign in with this provider. You can of course prevent users without a verified email address from using the app, and accessing the data.
  2. Through Email link. Here the user gets an email with a sign-in link, so their email address is implicitly verified as part of signing in.

If you want to require the user to verify their email address before they can sign in, it might be best to have them sign in through an email link.

In addition to @Frank's answer, when a user signs up you can send verification email to them. You can always check if the user has verified their email in your app by checking the isEmailVerified property as well as in security rules.

Talking of database storage, you can run a scheduled cloud function every midnight to delete data of users who have not verified their email. You can refer to this answer for a detailed explanation on periodically deleting unverified users.

Related