Search code examples
androidflutterfirebasedart

How to manually set the FirebaseAuth User emailVerified status to true


So, I am creating a flutter app. I am at learning stage, however I am a laravel web developer so I grasped things quickly and created an Login Register and OTP verification views. I used a dependency to send otp verification email and verify the otp in my app. But after the OTP is verified I want to use FirebaseAuth User isEmailVerified method to check either the email is verified or not when the user logs in again. I searched very deeply but there is no any workaround for this. I got to find that admin sdk can do this but I am not being able to find any solution for flutter. Is there anyway I can change the status to true manually ?

I tried verifyBeforeUpdateEmail with hoping that it will verify the email but It didn't work. I found the updateProfile method but that also couldn't update the verification status.


Solution

  • There is no way to set the email verified status of an account from your Flutter application code directly, as that'd mean that anyone can write code to do the same - even when your conditions haven't been met.

    For that reason setting the email verified status can only be done from a trusted environment, such as your development machine, a server that you control, or an environment like Cloud Functions/Cloud Run.

    If you want to trigger the email verified status change from your Flutter application, you can:

    • Implement a Cloud Function or other API endpoint where you use the Firebase Admin SDK to set the email verified status.
    • In that code, verify that the caller has met your conditions for changing the email verified status.
    • Call that endpoint from your Flutter application code.

    Also see: