From ef1b18b537820a2cde4554166e3b69274bccf3ae Mon Sep 17 00:00:00 2001 From: Andrew Blair Date: Wed, 8 Feb 2017 11:51:44 -0800 Subject: [PATCH 1/7] Corrections in docs A couple mistakes in the docs that I tracked down in terms of keys and values for credentials. --- docs/api/authentication.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/api/authentication.md b/docs/api/authentication.md index 84cb5bb..220f7e3 100644 --- a/docs/api/authentication.md +++ b/docs/api/authentication.md @@ -100,9 +100,9 @@ Sign in the user with a 3rd party credential provider. `credential` requires the ```javascript const credential = { - provider: 'facebook', - token: '12345', - secret: '6789', + provider: 'facebook.com', + accessToken: '12345', + //secret: '6789', //'secret' does not apply to facebook authentication }; firestack.auth().signInWithCredential(credential) From 2b944b85534d47f5aa8104349d605cabe840f671 Mon Sep 17 00:00:00 2001 From: Andrew Blair Date: Mon, 13 Feb 2017 08:23:28 -0800 Subject: [PATCH 2/7] Fixed facebook/google provider strings Changed from facebook and google to facebook.com and google.com respectively. This is needed for cross platform apps. These strings are now consistent with the [iOS](https://github.com/fullstackreact/react-native-firestack/blob/v3/ios/Firestack/FirestackAuth.m#L444) and [Web](https://firebase.google.com/docs/reference/js/firebase.auth.AuthCredential) code. Docs should be updated too. [Here's my pull request](https://github.com/fullstackreact/react-native-firestack/pull/284/files) for that. --- .../main/java/io/fullstack/firestack/auth/FirestackAuth.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/android/src/main/java/io/fullstack/firestack/auth/FirestackAuth.java b/android/src/main/java/io/fullstack/firestack/auth/FirestackAuth.java index 3f194ba..c485230 100644 --- a/android/src/main/java/io/fullstack/firestack/auth/FirestackAuth.java +++ b/android/src/main/java/io/fullstack/firestack/auth/FirestackAuth.java @@ -159,9 +159,9 @@ public void onComplete(@NonNull Task task) { @ReactMethod public void signInWithProvider(final String provider, final String authToken, final String authSecret, final Callback callback) { - if (provider.equals("facebook")) { + if (provider.equals("facebook.com")) { this.facebookLogin(authToken, callback); - } else if (provider.equals("google")) { + } else if (provider.equals("google.com")) { this.googleLogin(authToken, callback); } else // TODO From 3c892e8d7c5b86a9e9be16c93be66ee94a289501 Mon Sep 17 00:00:00 2001 From: Andrew Blair Date: Mon, 13 Feb 2017 08:34:15 -0800 Subject: [PATCH 3/7] API bug fix for signInWithCredential Solution discovered by @TheNarie in [this issue](https://github.com/fullstackreact/react-native-firestack/issues/282) except I also corrected `accessToken` from the original suggestion. Docs also updated about that in same pull request. --- lib/modules/auth/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/modules/auth/index.js b/lib/modules/auth/index.js index 61ef65e..af2bdfe 100644 --- a/lib/modules/auth/index.js +++ b/lib/modules/auth/index.js @@ -151,7 +151,7 @@ export default class Auth extends Base { * @return {Promise} A promise resolved upon completion */ signInWithCredential(credential: any): Promise { - return promisify('signInWithProvider', FirestackAuth)(credential); + return promisify('signInWithProvider', FirestackAuth)(credential.provider, credential.accessToken, credential.secret); } /** From 98a3d2c20d12600fd47399dfc531062b82b7b041 Mon Sep 17 00:00:00 2001 From: Andrew Blair Date: Mon, 13 Feb 2017 11:47:20 -0800 Subject: [PATCH 4/7] Fix for iOS and Android compatibility The iOS and Android, `signInWithProvider` have different signatures. This works around that difference but ideally the native signatures should match each other (and the Web sdk's). Tested on iOS and Android. --- lib/modules/auth/index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/modules/auth/index.js b/lib/modules/auth/index.js index af2bdfe..c2cb3bc 100644 --- a/lib/modules/auth/index.js +++ b/lib/modules/auth/index.js @@ -151,7 +151,12 @@ export default class Auth extends Base { * @return {Promise} A promise resolved upon completion */ signInWithCredential(credential: any): Promise { - return promisify('signInWithProvider', FirestackAuth)(credential.provider, credential.accessToken, credential.secret); + signInWithCredential(credential: any): Promise { + if (Platform.OS === 'ios'){ + return promisify('signInWithProvider', FirestackAuth)(credential); + }else{ //Android + return promisify('signInWithProvider', FirestackAuth)(credential.provider, credential.accessToken, credential.secret); + } } /** From 8e79615b3c992dc324cec6559d08c9c78c5d44d4 Mon Sep 17 00:00:00 2001 From: Andrew Blair Date: Mon, 13 Feb 2017 11:48:34 -0800 Subject: [PATCH 5/7] Forgot to import Platform needed for previous commit. --- lib/modules/auth/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/modules/auth/index.js b/lib/modules/auth/index.js index c2cb3bc..0a0757d 100644 --- a/lib/modules/auth/index.js +++ b/lib/modules/auth/index.js @@ -1,5 +1,5 @@ // @flow -import { NativeModules, NativeEventEmitter } from 'react-native'; +import { NativeModules, NativeEventEmitter, Platform } from 'react-native'; import User from './../user'; import { Base } from './../base'; From d47aecb09b900a4a054a85a2d4af76af8d9ddaf8 Mon Sep 17 00:00:00 2001 From: Andrew Blair Date: Mon, 13 Feb 2017 11:51:27 -0800 Subject: [PATCH 6/7] Bug fix in Android for `dbRef.on('value'...)` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit One of the needed parameters was named incorrectly – on Android this resulted in no data being retrieved. This fixes it. --- android/src/main/java/io/fullstack/firestack/Utils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/src/main/java/io/fullstack/firestack/Utils.java b/android/src/main/java/io/fullstack/firestack/Utils.java index a763204..b5ab91f 100644 --- a/android/src/main/java/io/fullstack/firestack/Utils.java +++ b/android/src/main/java/io/fullstack/firestack/Utils.java @@ -105,7 +105,7 @@ public static WritableMap dataSnapshotToMap( WritableMap eventMap = Arguments.createMap(); eventMap.putString("eventName", name); eventMap.putMap("snapshot", data); - eventMap.putString("path", path); + eventMap.putString("handlePath", path); eventMap.putString("modifiersString", modifiersString); return eventMap; } From 651ffdf93630c97427dafe13e06fdc6fd9de00a2 Mon Sep 17 00:00:00 2001 From: Andrew Blair Date: Thu, 16 Feb 2017 10:51:18 -0800 Subject: [PATCH 7/7] Fixed duplicate line --- lib/modules/auth/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/modules/auth/index.js b/lib/modules/auth/index.js index 0a0757d..c44257f 100644 --- a/lib/modules/auth/index.js +++ b/lib/modules/auth/index.js @@ -151,7 +151,6 @@ export default class Auth extends Base { * @return {Promise} A promise resolved upon completion */ signInWithCredential(credential: any): Promise { - signInWithCredential(credential: any): Promise { if (Platform.OS === 'ios'){ return promisify('signInWithProvider', FirestackAuth)(credential); }else{ //Android