Skip to content

Commit 530a43a

Browse files
[firebase_auth] Fix NoSuchMethodError exception in reauthenticateWithCredential (#237)
* [firebase_auth] Fix NoSuchMethodError exception Fix NoSuchMethodError exception when calling FirebaseUser.reauthenticateWithCredential * add integration test * Fix analyzer warnings Co-Authored-By: Collin Jackson <[email protected]>
1 parent d743f16 commit 530a43a

File tree

7 files changed

+25
-12
lines changed

7 files changed

+25
-12
lines changed

packages/firebase_auth/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 0.15.0
2+
3+
* Fixed `NoSuchMethodError` in `reauthenticateWithCredential`.
4+
* Fixed `IdTokenResult` analyzer warnings.
5+
* Reduced visibility of `IdTokenResult` constructor.
6+
17
## 0.14.0+10
28

39
* Formatted lists in member documentations for better readability.

packages/firebase_auth/android/src/main/java/io/flutter/plugins/firebaseauth/FirebaseAuthPlugin.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -491,8 +491,8 @@ private void handleReauthenticateWithCredential(
491491
AuthCredential credential = getCredential((Map<String, Object>) call.arguments());
492492

493493
currentUser
494-
.reauthenticate(credential)
495-
.addOnCompleteListener(new TaskVoidCompleteListener(result));
494+
.reauthenticateAndRetrieveData(credential)
495+
.addOnCompleteListener(new SignInCompleteListener(result));
496496
}
497497

498498
private void handleUnlinkFromProvider(MethodCall call, Result result, FirebaseAuth firebaseAuth) {

packages/firebase_auth/example/test/firebase_auth.dart

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,15 @@ void main() {
9292
await auth.fetchSignInMethodsForEmail(email: testEmail);
9393
expect(methods.length, 1);
9494
expect(methods[0], 'password');
95-
await user.delete();
95+
final AuthResult renewResult =
96+
await result.user.reauthenticateWithCredential(
97+
EmailAuthProvider.getCredential(
98+
email: testEmail,
99+
password: testPassword,
100+
),
101+
);
102+
expect(renewResult.user.uid, equals(user.uid));
103+
await renewResult.user.delete();
96104
});
97105

98106
test('isSignInWithEmailLink', () async {

packages/firebase_auth/ios/Classes/FirebaseAuthPlugin.m

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,11 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result
238238
} else if ([@"reauthenticateWithCredential" isEqualToString:call.method]) {
239239
[[self getAuth:call.arguments].currentUser
240240
reauthenticateAndRetrieveDataWithCredential:[self getCredential:call.arguments]
241-
completion:^(FIRAuthDataResult *r,
242-
NSError *_Nullable error) {
243-
[self sendResult:result forObject:nil error:error];
241+
completion:^(FIRAuthDataResult *authResult,
242+
NSError *error) {
243+
[self sendResult:result
244+
forAuthDataResult:authResult
245+
error:error];
244246
}];
245247
} else if ([@"linkWithCredential" isEqualToString:call.method]) {
246248
[[self getAuth:call.arguments].currentUser

packages/firebase_auth/lib/src/firebase_user.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class FirebaseUser extends UserInfo {
4040
'app': _app.name,
4141
});
4242

43-
return IdTokenResult(data, _app);
43+
return IdTokenResult._(data);
4444
}
4545

4646
/// Associates a user account from a third-party identity provider with this

packages/firebase_auth/lib/src/id_token_result.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@ part of firebase_auth;
1212
/// Only server side verification can guarantee the integrity of the token
1313
/// claims.
1414
class IdTokenResult {
15-
@visibleForTesting
16-
IdTokenResult(this._data, this._app);
17-
18-
final FirebaseApp _app;
15+
IdTokenResult._(this._data);
1916

2017
final Map<dynamic, dynamic> _data;
2118

packages/firebase_auth/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Flutter plugin for Firebase Auth, enabling Android and iOS
44
like Google, Facebook and Twitter.
55
author: Flutter Team <[email protected]>
66
homepage: https://github.com/FirebaseExtended/flutterfire/tree/master/packages/firebase_auth
7-
version: 0.14.0+10
7+
version: 0.15.0
88

99
flutter:
1010
plugin:

0 commit comments

Comments
 (0)