onAuthStateChanged doesn't get called when email is verified in flutter

后端 未结 4 1082
心在旅途
心在旅途 2021-01-15 13:29

When a user signs up in my app he gets a verification e-mail. The onAuthStateChanged-listener gets called when a user gets created using createUserWithEma

相关标签:
4条回答
  • 2021-01-15 13:42

    At the moment I'm providing a button to 'complete email validation'. This calls User.reload - so this appears to be enough per @Frank van Puffelen's comment above. It's much less satisfactory than getting a status update event; I may implement a loop to check the status for a period after sending an email so that the app passes through automatically.

    0 讨论(0)
  • 2021-01-15 13:44

    onAuthStatechanged is triggered only in case of user Login or Logout & not on Email verification.

    As Per Doc -

    onAuthStatechanged Adds an observer for changes to the user's sign-in state.

    The observer will be triggered in the following scenarios:

    • When auth().onAuthStateChanged() is first called. It will trigger with the initial Auth state. If the user is returning from an auth().signInWithRedirect() operation, the observer will wait for that operation to resolve before initially triggering.

    • When a new user signs.

    • When an already signed in user signs out.

    0 讨论(0)
  • 2021-01-15 14:04

    You can simply do a firebase.auth().signOut after sending the email verification link. And when the user clicks on sign in again, it'll automatically fire onAuthStateChanged.

    0 讨论(0)
  • 2021-01-15 14:07

    Use the where Function:

    final FirebaseAuth _firebaseAuth = FirebaseAuth.instance;
    
      Stream<FirebaseUser> get onAuthStateChanged {
        return _firebaseAuth.onAuthStateChanged.where((user)=> user.isEmailVerified);
      }
    
    0 讨论(0)
提交回复
热议问题