Closed
Description
description
- I use firebase_auth: 0.14.0.
- I would like to update the user's email, but if the user's last sign-in time does not meet the security threshold, I need to use the reauthentication method to resolve.
- I tried to call
reauthenticateWithCredential
onEmailAuthProvider
with my current email address and password beforefirebaseUser.updateEmail
, but the data returned fromreauthenticateWithCredential
on iOS has no user and crashes with the following error.
error
Tried calling: []("user")
flutter: 💥 #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:50:5)
#1 new AuthResult._ (package:firebase_auth/src/auth_result.dart:12:36)
#2 FirebaseUser.reauthenticateWithCredential (package:firebase_auth/src/firebase_user.dart:214:23)
...
my code
final baseUser = await _firebaseAuth.currentUser();
// occurs error
final authResult = await baseUser.reauthenticateWithCredential(
EmailAuthProvider.getCredential(
email: baseUser.email,
password: password,
),
);
return authResult.user;
workaround
- I downgraded to 0.11.1+12, and it works.
final baseUser = await _firebaseAuth.currentUser();
final firebaseUser = await baseUser.reauthenticateWithCredential(
EmailAuthProvider.getCredential(
email: baseUser.email,
password: password,
),
);
return firebaseUser;