diff --git a/packages/firebase_auth/CHANGELOG.md b/packages/firebase_auth/CHANGELOG.md index 104de5398129..ad53440bbcc3 100644 --- a/packages/firebase_auth/CHANGELOG.md +++ b/packages/firebase_auth/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.6.7 + +* Adding support for FirebaseUser.unlink(providerId) + ## 0.6.5 * Fixing async method `verifyPhoneNumber`, that would never return even in a successful call. diff --git a/packages/firebase_auth/android/src/main/java/io/flutter/plugins/firebaseauth/FirebaseAuthPlugin.java b/packages/firebase_auth/android/src/main/java/io/flutter/plugins/firebaseauth/FirebaseAuthPlugin.java index a3a68ded7497..d6e12a14f150 100755 --- a/packages/firebase_auth/android/src/main/java/io/flutter/plugins/firebaseauth/FirebaseAuthPlugin.java +++ b/packages/firebase_auth/android/src/main/java/io/flutter/plugins/firebaseauth/FirebaseAuthPlugin.java @@ -136,6 +136,8 @@ public void onMethodCall(MethodCall call, Result result) { break; case "linkWithTwitterCredential": handleLinkWithTwitterCredential(call, result, getAuth(call)); + case "unlink": + handleUnlink(call, result, getAuth(call)); break; case "linkWithGithubCredential": handleLinkWithGithubCredential(call, result, getAuth(call)); @@ -538,6 +540,15 @@ private void handleSignInWithCustomToken( .addOnCompleteListener(new SignInCompleteListener(result)); } + private void handleUnlink(MethodCall call, final Result result, FirebaseAuth firebaseAuth) { + Map arguments = call.arguments(); + String providerId = arguments.get("providerId"); + firebaseAuth + .getCurrentUser() + .unlink(providerId) + .addOnCompleteListener(new SignInCompleteListener(result)); + } + private void handleSignOut(MethodCall call, final Result result, FirebaseAuth firebaseAuth) { firebaseAuth.signOut(); result.success(null); diff --git a/packages/firebase_auth/ios/Classes/FirebaseAuthPlugin.m b/packages/firebase_auth/ios/Classes/FirebaseAuthPlugin.m index ebac80fea00e..483c9ffa581d 100644 --- a/packages/firebase_auth/ios/Classes/FirebaseAuthPlugin.m +++ b/packages/firebase_auth/ios/Classes/FirebaseAuthPlugin.m @@ -266,6 +266,14 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result forUser:user error:error]; }]; + } else if ([@"unlink" isEqualToString:call.method]) { + NSString *providerId = call.arguments[@"providerId"]; + [[self getAuth:call.arguments].currentUser unlinkFromProvider:providerId + completion:^(FIRUser *user, NSError *error) { + [self sendResult:result + forUser:user + error:error]; + }]; } else if ([@"updateEmail" isEqualToString:call.method]) { NSString *email = call.arguments[@"email"]; [[self getAuth:call.arguments].currentUser updateEmail:email diff --git a/packages/firebase_auth/lib/firebase_auth.dart b/packages/firebase_auth/lib/firebase_auth.dart index 9392695bf837..c2b513f1ef81 100755 --- a/packages/firebase_auth/lib/firebase_auth.dart +++ b/packages/firebase_auth/lib/firebase_auth.dart @@ -549,6 +549,20 @@ class FirebaseAuth { {'app': app.name, 'token': token}); } + Future unlink({ + @required String providerId, + }) async { + final Map data = await channel.invokeMethod( + 'unlink', + { + 'app': app.name, + 'providerId': providerId, + }, + ); + final FirebaseUser currentUser = FirebaseUser._(data, app); + return currentUser; + } + /// Sets the user-facing language code for auth operations that can be /// internationalized, such as [sendEmailVerification]. This language /// code should follow the conventions defined by the IETF in BCP47. diff --git a/packages/firebase_auth/pubspec.yaml b/packages/firebase_auth/pubspec.yaml index b6da2330f184..99007c3eac20 100755 --- a/packages/firebase_auth/pubspec.yaml +++ b/packages/firebase_auth/pubspec.yaml @@ -4,7 +4,7 @@ description: Flutter plugin for Firebase Auth, enabling Android and iOS like Google, Facebook and Twitter. author: Flutter Team homepage: https://github.com/flutter/plugins/tree/master/packages/firebase_auth -version: 0.6.6 +version: 0.6.7 flutter: plugin: diff --git a/packages/firebase_auth/test/firebase_auth_test.dart b/packages/firebase_auth/test/firebase_auth_test.dart index 868d4ff3e9cd..cad958315eab 100755 --- a/packages/firebase_auth/test/firebase_auth_test.dart +++ b/packages/firebase_auth/test/firebase_auth_test.dart @@ -383,6 +383,25 @@ void main() { ); }); + test('unlink', () async { + final FirebaseUser user = await auth.unlink( + providerId: kMockProviderId, + ); + verifyUser(user); + expect( + log, + [ + isMethodCall( + 'unlink', + arguments: { + 'app': auth.app.name, + 'providerId': kMockProviderId, + }, + ), + ], + ); + }); + test('signInWithFacebook', () async { final FirebaseUser user = await auth.signInWithFacebook( accessToken: kMockAccessToken,