From 89f4cea470f5d797fc643b305b40b88e9887cc9a Mon Sep 17 00:00:00 2001 From: ko2ic Date: Fri, 3 Aug 2018 09:40:27 +0900 Subject: [PATCH 1/3] Adding support for FirebaseUser.unlink(providerId) * Unlink an auth provider from a user account --- packages/firebase_auth/CHANGELOG.md | 1 + .../firebaseauth/FirebaseAuthPlugin.java | 11 +++++++++++ .../ios/Classes/FirebaseAuthPlugin.m | 8 ++++++++ packages/firebase_auth/lib/firebase_auth.dart | 14 ++++++++++++++ .../test/firebase_auth_test.dart | 19 +++++++++++++++++++ 5 files changed, 53 insertions(+) diff --git a/packages/firebase_auth/CHANGELOG.md b/packages/firebase_auth/CHANGELOG.md index 104de5398129..2bcf576459f5 100644 --- a/packages/firebase_auth/CHANGELOG.md +++ b/packages/firebase_auth/CHANGELOG.md @@ -9,6 +9,7 @@ ## 0.6.3 * Add multi app support. +* Adding support for FirebaseUser.unlink(providerId) ## 0.6.2+1 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/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, From 10ec041fd1fa5f2c3f612b6f321d9e5189cece44 Mon Sep 17 00:00:00 2001 From: Arthur Thompson Date: Tue, 20 Nov 2018 09:03:42 -0800 Subject: [PATCH 2/3] update changelog --- packages/firebase_auth/CHANGELOG.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/firebase_auth/CHANGELOG.md b/packages/firebase_auth/CHANGELOG.md index 2bcf576459f5..548268831f10 100644 --- a/packages/firebase_auth/CHANGELOG.md +++ b/packages/firebase_auth/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.6.6 + +* Adding support for FirebaseUser.unlink(providerId) + ## 0.6.5 * Fixing async method `verifyPhoneNumber`, that would never return even in a successful call. @@ -9,7 +13,6 @@ ## 0.6.3 * Add multi app support. -* Adding support for FirebaseUser.unlink(providerId) ## 0.6.2+1 From cdde055241e4de02322520f73a2565aa62486cb0 Mon Sep 17 00:00:00 2001 From: ko2ic Date: Wed, 21 Nov 2018 10:54:44 +0900 Subject: [PATCH 3/3] bump version to 0.6.7 --- packages/firebase_auth/CHANGELOG.md | 2 +- packages/firebase_auth/pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/firebase_auth/CHANGELOG.md b/packages/firebase_auth/CHANGELOG.md index 548268831f10..ad53440bbcc3 100644 --- a/packages/firebase_auth/CHANGELOG.md +++ b/packages/firebase_auth/CHANGELOG.md @@ -1,4 +1,4 @@ -## 0.6.6 +## 0.6.7 * Adding support for FirebaseUser.unlink(providerId) 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: