简体   繁体   中英

Firebase Auth – State Update on emailVerified

I have ignored the email/password sign up process and the necessary email verification for a long time and only used the very basic functionality to get started and build on top of that. But now I reached the point where I cannot avoid to use a more production-grade email/password sign up process. Currently I am using these Firebase services: Authentication (email/password only), Firestore and Cloud Functions with a react-native application.

When a user signed up successfully (signed in but without an verified email.) the react native application won't offer functionality until the user has verified his/her email, Right after the sign up the client will send an email with an verification link (through the default firebase server). the user can verify his/her email by clicking the link.

The issue: How to react suitable to a change of emailVerified or any other event which fires if the email got verified?

I have now searched the whole day for a working solution. These are my approaches:

  • Use your own website to which all verification links are linked (tried this but did not work at my first attempt)
  • use actionCodeSettings in the email verification link to redirect the user and let the client reload its components
  • Use Cloud Messaging and inform the client about changes to the email verification status
  • call a Cloud Function (from an external server) which updates a tmp document in Firestore to which the client subscribed
  • reload()/loop

I am thankful for all comments, helpful links etc.!

There is a method in the Firebase SDK: isEmailVerified() which tells if the user has verified the email or not.

For react native, I found straightforward documentation: Email Verified . On the launch of the app, you can check if the user has verified the email or not and then make changes accordingly!

Happy Coding!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM