I have a static AuthProvider class that centralizes all authentication.
I have the following registration code.
AuthResult newUser = await auth.createUserWithEmailAndPassword(
email: email, password: password);
if (newUser == null) {
print(
'AuthProvider: empty user is returned from createUserWithEmailAndPassword');
return false;
}
await newUser.user.sendEmailVerification();
return true;
After signing up on the app, I received a verification email, so I clicked on it. When I try to sign in next time, isEmailVerified is returning false. After some research, I think I am supposed to reload the user object as follows:
FirebaseUser user = await auth.currentUser();
await user.reload();
user = await auth.currentUser();
print('${user.isEmailVerified}');
Unfortunately, isEmailVerified is still returning false. Does anyone have any idea why this is happening?
The isEmailVerified
isn't updated until the next time an ID token is generated for the user.
You have a few options to accomplish this:
isEmailVerified
value.getIdToken(true)
or reload()
on the user, which forces it to refresh the ID token and thus get the updated isEmailVerified
value.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With