Skip to content

[fireabse_auth] call reauthenticateWithCredential by EmailAuthProvider using current email and password (NoSuchMethodError: The method '[]' was called on null). #1085

Closed
@kroikie

Description

@kroikie

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 on EmailAuthProvider with my current email address and password before firebaseUser.updateEmail, but the data returned from reauthenticateWithCredential 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;

Metadata

Metadata

Assignees

Labels

type: bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions