Firebase Authentication after email verification

Hi everybody,
I read many tutorial and tryed to find if what I want to show You already exists, but it seems no.
In few words I want that when I create a new user on Firebase an email verification is sent to verify the user and cannot access the database until he replies to the email. I said email verification not reset password email (really I don’t like this kind of solution).
In the aia project attached You will be able to:

  • create a new user, and automatically send an email verification
  • sign in (ony after the email is verified)
  • reset the password (if You need)
    For this purpose I use the Firebase REST API
    image
    Here the URL called in the project
    When I create a new user, after checked if all data are correct I use this URL that create a new user in the firebase
    image

Then I check if everything is ok


then i get the idToken tha I will use immediately after. At this point i call getUserEmailVerified
(obviously at this point the answer is false but I use this code also for the SignIn

Because the I just added a new user (SignUpCheck=true) I SendEmail fot the verification.
After I will show You what happen with Clock1.TimerEnabled= true

Now we go to see what happen with getUserEmailVerified:
image
with the UserData URL and the idToken received before I check if the value emailVerified is true (the user replied to the email sent) or false (not yet replied)

SendEmail obviously send the email verification using the ConfirmEmail url and the idToken received before
image

And this the reply to the two previous URL request, I check only the status of the email

Last the Clock, i use it because I need to wait the answer about the status of the emailverified
image
At this point if is it true the user is authorized to use the firebase database.

I hope is clear, but it will be easier watching the .aia project.
Best Regards
Marco Perrone
AccessControl.aia (646.0 KB)

2 Likes