amele cono
amele cono

Reputation: 23

Firebase Prevent Creating Account Before Email Verification

I am working on an android project that includes user sign-in with email. But the problem is this. When I create test account it immediately appears in the firebase authentication section without verification. But it also sends verification mail. I want to prevent this. Because for example if somebody enters my email address and they can not click verification link because it comes to my mailbox. But when I try to sign-up with my normal mail address app crashes and it is not sending verification mail again. My goal is to prevent account creating without verification and sending verification email on second or third or whatever try.

Upvotes: 2

Views: 1796

Answers (1)

bojeil
bojeil

Reputation: 30848

If you require only verified accounts, then you should enforce it via security rules.

"$uid": {
  ".read": "auth != null && auth.uid == $uid && auth.token.email_verified === true",
  ".write": "auth != null && auth.uid == $uid && auth.token.email_verified === true"
}

If you don't like that the account was created and discarded, you can write an offline job using the Firebase Admin SDK to clean up unverified accounts after some time.

You can't verify the email before creating the account.

Upvotes: 1

Related Questions