Burak
Burak

Reputation: 2117

Let user know when email verified

When the user wants to update the email, I'm using verifyBeforeUpdateEmail to verify before updating it.

await FirebaseAuth.instance.currentUser.verifyBeforeUpdateEmail(
    email,
    ActionCodeSettings(
      androidInstallApp: true,
      androidPackageName: 'com.example',
      iOSBundleId: 'com.example',
      handleCodeInApp: true,
      url: 'https://example.page.link/emailVerify',
    ));

Can I let the user know if the email has been verified and updated? I've tried dynamic_links but it does not pick up the email verification.

Upvotes: 0

Views: 443

Answers (1)

Renaud Tarnec
Renaud Tarnec

Reputation: 83103

The verifyBeforeUpdateEmail() method sends a verification email to a new email address. So the user needs to execute an action in order to verify the email (click on the link provided in the email). So normally the user will know he/she has verified the new email.

If you want to add an extra mechanism to "let the user know if the email has been verified and updated" you could adopt one of the following approaches:

#1 Implement a custom email action handler

As explained in the doc, "by default, user management emails link to the default action handler, which is a web page hosted at a URL in your project's Firebase Hosting domain. You can instead create and host a custom email action handler to do custom processing and to integrate the email action handler with your website".

This way, you could implement any business logic in parallel of the email verification, like sending a confirmation email or updating a flag, etc..

#2 Use a Cloud Function

There is no Authentication Cloud Functions trigger in response to the verification of an email, unfortunately. We can only trigger a Cloud Function upon the creation and deletion of Firebase user accounts. But you could implement a scheduled Cloud Function which checks if the email has been verified.

Upvotes: 1

Related Questions