diff --git a/.gitignore b/.gitignore index ccb0eeb34605..497f359590af 100644 --- a/.gitignore +++ b/.gitignore @@ -40,3 +40,5 @@ build/ .project .classpath .settings + +**/.flutter-plugins-dependencies \ No newline at end of file diff --git a/packages/firebase_auth/firebase_auth/CHANGELOG.md b/packages/firebase_auth/firebase_auth/CHANGELOG.md index 35dbe944cbd0..8f1b06f8d82d 100644 --- a/packages/firebase_auth/firebase_auth/CHANGELOG.md +++ b/packages/firebase_auth/firebase_auth/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.15.4 + +* Add support for confirmPasswordReset + ## 0.15.3 * Add support for OAuth Authentication for iOS and Android to solve generic providers authentication. diff --git a/packages/firebase_auth/firebase_auth/android/src/main/java/io/flutter/plugins/firebaseauth/FirebaseAuthPlugin.java b/packages/firebase_auth/firebase_auth/android/src/main/java/io/flutter/plugins/firebaseauth/FirebaseAuthPlugin.java index 13c233c2cee9..553292497d32 100755 --- a/packages/firebase_auth/firebase_auth/android/src/main/java/io/flutter/plugins/firebaseauth/FirebaseAuthPlugin.java +++ b/packages/firebase_auth/firebase_auth/android/src/main/java/io/flutter/plugins/firebaseauth/FirebaseAuthPlugin.java @@ -165,6 +165,8 @@ public void onMethodCall(MethodCall call, Result result) { case "setLanguageCode": handleSetLanguageCode(call, result, getAuth(call)); break; + case "confirmPasswordReset": + handleConfirmPasswordReset(call, result, getAuth(call)); default: result.notImplemented(); break; @@ -694,6 +696,16 @@ private void handleSetLanguageCode(MethodCall call, Result result, FirebaseAuth result.success(null); } + private void handleConfirmPasswordReset( + MethodCall call, Result result, FirebaseAuth firebaseAuth) { + Map arguments = call.arguments(); + String oobCode = arguments.get("oobCode"); + String newPassword = arguments.get("newPassword"); + + firebaseAuth.confirmPasswordReset(oobCode, newPassword); + result.success(null); + } + private class SignInCompleteListener implements OnCompleteListener { private final Result result; diff --git a/packages/firebase_auth/firebase_auth/ios/Classes/FLTFirebaseAuthPlugin.m b/packages/firebase_auth/firebase_auth/ios/Classes/FLTFirebaseAuthPlugin.m index a641d136c04e..d80ea6521baf 100644 --- a/packages/firebase_auth/firebase_auth/ios/Classes/FLTFirebaseAuthPlugin.m +++ b/packages/firebase_auth/firebase_auth/ios/Classes/FLTFirebaseAuthPlugin.m @@ -371,6 +371,11 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result NSString *language = call.arguments[@"language"]; [[self getAuth:call.arguments] setLanguageCode:language]; [self sendResult:result forObject:nil error:nil]; + } else if ([@"confirmPasswordReset" isEqualToString:call.method]) { + NSString *oobCode = call.arguments[@"oobCode"]; + NSString *newPassword = call.arguments[@"newPassword"]; + [[self getAuth:call.arguments] confirmPasswordResetWithCode:oobCode newPassword:newPassword]; + [self sendResult:result forObject:nil error:nil]; } else { result(FlutterMethodNotImplemented); } diff --git a/packages/firebase_auth/firebase_auth/lib/src/firebase_auth.dart b/packages/firebase_auth/firebase_auth/lib/src/firebase_auth.dart index 4695b6c0fcec..5ea8ea5d78a0 100644 --- a/packages/firebase_auth/firebase_auth/lib/src/firebase_auth.dart +++ b/packages/firebase_auth/firebase_auth/lib/src/firebase_auth.dart @@ -326,4 +326,17 @@ class FirebaseAuth { assert(language != null); return FirebaseAuthPlatform.instance.setLanguageCode(app.name, language); } + + /// Completes the password reset process, given a confirmation code and new password. + /// + /// Errors: + /// `EXPIRED_ACTION_CODE` - if the password reset code has expired. + /// `INVALID_ACTION_CODE` - if the password reset code is invalid. This can happen if the code is malformed or has already been used. + /// `USER_DISABLED` - if the user corresponding to the given password reset code has been disabled. + /// `USER_NOT_FOUND` - if there is no user corresponding to the password reset code. This may have happened if the user was deleted between when the code was issued and when this method was called. + /// `WEAK_PASSWORD` - if the new password is not strong enough. + Future confirmPasswordReset(String oobCode, String newPassword) { + return FirebaseAuthPlatform.instance + .confirmPasswordReset(oobCode, newPassword); + } } diff --git a/packages/firebase_auth/firebase_auth/pubspec.yaml b/packages/firebase_auth/firebase_auth/pubspec.yaml index e8b4e8f46240..613f5f92eb34 100755 --- a/packages/firebase_auth/firebase_auth/pubspec.yaml +++ b/packages/firebase_auth/firebase_auth/pubspec.yaml @@ -3,7 +3,7 @@ description: Flutter plugin for Firebase Auth, enabling Android and iOS authentication using passwords, phone numbers and identity providers like Google, Facebook and Twitter. homepage: https://github.com/FirebaseExtended/flutterfire/tree/master/packages/firebase_auth/firebase_auth -version: 0.15.3 +version: 0.15.4 flutter: plugin: diff --git a/packages/firebase_auth/firebase_auth/test/firebase_auth_test.dart b/packages/firebase_auth/firebase_auth/test/firebase_auth_test.dart index f333e570f7fe..a05c50febadc 100755 --- a/packages/firebase_auth/firebase_auth/test/firebase_auth_test.dart +++ b/packages/firebase_auth/firebase_auth/test/firebase_auth_test.dart @@ -28,6 +28,7 @@ const String kMockVerificationId = '12345'; const String kMockSmsCode = '123456'; const String kMockLanguage = 'en'; const String kMockIdTokenResultSignInProvider = 'password'; +const String kMockOobCode = 'oobcode'; const Map kMockIdTokenResultClaims = { 'claim1': 'value1', }; @@ -876,6 +877,11 @@ void main() { await auth.setLanguageCode(kMockLanguage); verify(mock.setLanguageCode(auth.app.name, kMockLanguage)); }); + + test('confirmPasswordReset', () async { + await auth.confirmPasswordReset(kMockOobCode, kMockPassword); + verify(mock.confirmPasswordReset(kMockOobCode, kMockPassword)); + }); }); } diff --git a/packages/firebase_auth/firebase_auth_platform_interface/CHANGELOG.md b/packages/firebase_auth/firebase_auth_platform_interface/CHANGELOG.md index 48c5833a875b..269f6b0092b9 100644 --- a/packages/firebase_auth/firebase_auth_platform_interface/CHANGELOG.md +++ b/packages/firebase_auth/firebase_auth_platform_interface/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.1.3 + +- Added `confirmPasswordReset` + ## 1.1.2 - Remove the deprecated `author:` field from pubspec.yaml diff --git a/packages/firebase_auth/firebase_auth_platform_interface/lib/firebase_auth_platform_interface.dart b/packages/firebase_auth/firebase_auth_platform_interface/lib/firebase_auth_platform_interface.dart index 806054a7e4db..0580c65e8ec8 100644 --- a/packages/firebase_auth/firebase_auth_platform_interface/lib/firebase_auth_platform_interface.dart +++ b/packages/firebase_auth/firebase_auth_platform_interface/lib/firebase_auth_platform_interface.dart @@ -231,4 +231,8 @@ abstract class FirebaseAuthPlatform { }) { throw UnimplementedError('verifyPhoneNumber() is not implemented'); } + + Future confirmPasswordReset(String oobCode, String newPassword) { + throw UnimplementedError('confirmPasswordReset() is not implemented'); + } } diff --git a/packages/firebase_auth/firebase_auth_platform_interface/lib/src/method_channel_firebase_auth.dart b/packages/firebase_auth/firebase_auth_platform_interface/lib/src/method_channel_firebase_auth.dart index 4bd4b51c2d32..09ad3737899e 100644 --- a/packages/firebase_auth/firebase_auth_platform_interface/lib/src/method_channel_firebase_auth.dart +++ b/packages/firebase_auth/firebase_auth_platform_interface/lib/src/method_channel_firebase_auth.dart @@ -352,6 +352,14 @@ class MethodChannelFirebaseAuth extends FirebaseAuthPlatform { return channel.invokeMethod('verifyPhoneNumber', params); } + @override + Future confirmPasswordReset(String oobCode, String newPassword) { + return channel.invokeMethod('confirmPasswordReset', { + 'oobCode': oobCode, + 'newPassword': newPassword, + }); + } + Future _callHandler(MethodCall call) async { switch (call.method) { case 'onAuthStateChanged': @@ -468,7 +476,7 @@ PlatformIdTokenResult _decodeIdTokenResult(Map data) { ); } -/// A utilily class that collects the callbacks for a [verifyPhoneNumber] call. +/// A utility class that collects the callbacks for a [verifyPhoneNumber] call. class _PhoneAuthCallbacks { const _PhoneAuthCallbacks( this.verificationCompleted, diff --git a/packages/firebase_auth/firebase_auth_platform_interface/pubspec.yaml b/packages/firebase_auth/firebase_auth_platform_interface/pubspec.yaml index b82db43ba02c..3663f83f462d 100644 --- a/packages/firebase_auth/firebase_auth_platform_interface/pubspec.yaml +++ b/packages/firebase_auth/firebase_auth_platform_interface/pubspec.yaml @@ -3,7 +3,7 @@ description: A common platform interface for the firebase_auth plugin. homepage: https://github.com/FirebaseExtended/flutterfire/tree/master/packages/firebase_auth/firebase_auth_platform_interface # NOTE: We strongly prefer non-breaking changes, even at the expense of a # less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes -version: 1.1.2 +version: 1.1.3 dependencies: flutter: diff --git a/packages/firebase_auth/firebase_auth_platform_interface/test/method_channel_firebase_auth_test.dart b/packages/firebase_auth/firebase_auth_platform_interface/test/method_channel_firebase_auth_test.dart index a53bbf32f359..d0f290f009f4 100644 --- a/packages/firebase_auth/firebase_auth_platform_interface/test/method_channel_firebase_auth_test.dart +++ b/packages/firebase_auth/firebase_auth_platform_interface/test/method_channel_firebase_auth_test.dart @@ -25,6 +25,7 @@ const String kMockVerificationId = '12345'; const String kMockSmsCode = '123456'; const String kMockLanguage = 'en'; const String kMockIdTokenResultSignInProvider = 'password'; +const String kMockOobCode = 'oobcode'; const Map kMockIdTokenResultClaims = { 'claim1': 'value1', }; @@ -1335,6 +1336,23 @@ void main() { ], ); }); + + test('confirmPasswordReset', () async { + await auth.confirmPasswordReset(kMockOobCode, kMockPassword); + + expect( + log, + [ + isMethodCall( + 'confirmPasswordReset', + arguments: { + 'oobCode': kMockOobCode, + 'newPassword': kMockPassword, + }, + ), + ], + ); + }); }); }