Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
masashi-sutou opened this issue Aug 3, 2019 · 8 comments
Labels
p: firebase_auth The Firebase Auth plugin package flutter/packages repository. See also p: labels.

Comments

@masashi-sutou
Copy link
Contributor

masashi-sutou commented Aug 3, 2019

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;
@masashi-sutou masashi-sutou changed the title [fireabse_auth] NoSuchMethodError: The method '[]' was called on null. [fireabse_auth] call reauthenticateWithCredential by EmailAuthProvider using current email and password (NoSuchMethodError: The method '[]' was called on null). Aug 3, 2019
@MiguelSOliveira
Copy link

MiguelSOliveira commented Aug 3, 2019

Getting the same error here.. Workaround also works for me, but don't really like to have to downgrade..

@masashi-sutou
Copy link
Contributor Author

but don't really like to have to downgrade..

@MiguelSOliveira What's your workaround without downgrading?

@AndreHaueisen
Copy link

I'm getting the same error with PhoneAuthProvider.

@AndreHaueisen
Copy link

The problem was probably generated on this commit

Trying to debug it

@Akyna
Copy link

Akyna commented Aug 27, 2019

any update ?

@rodriigovieira
Copy link

I was able to reproduce the problem here.

Another possible workaround is simply reauthenticate the user again.

await _auth.signInWithEmailAndPassword(email: _user.email, password: currentPassword);

@kroikie
Copy link

kroikie commented Oct 13, 2019

@masashi-sutou

This issue has been moved to firebase/flutterfire#1085. Any further collaboration will be done there.

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 27, 2021
@flutter-triage-bot flutter-triage-bot bot added the package flutter/packages repository. See also p: labels. label Jul 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p: firebase_auth The Firebase Auth plugin package flutter/packages repository. See also p: labels.
Projects
None yet
Development

No branches or pull requests

7 participants