From 64261f1ac9d8bf5c4a261d73ff5e9291566c63ea Mon Sep 17 00:00:00 2001 From: Chaitanya Bhagvan Date: Wed, 23 Nov 2016 17:36:44 +0530 Subject: [PATCH 1/3] getToken(true) will try to fetch token from server and fail if offline. --- android/src/main/java/io/fullstack/firestack/FirestackAuth.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/src/main/java/io/fullstack/firestack/FirestackAuth.java b/android/src/main/java/io/fullstack/firestack/FirestackAuth.java index 36dd584..b0743e2 100644 --- a/android/src/main/java/io/fullstack/firestack/FirestackAuth.java +++ b/android/src/main/java/io/fullstack/firestack/FirestackAuth.java @@ -518,7 +518,7 @@ public void userCallback(FirebaseUser passedUser, final Callback callback) { this.user = passedUser; } - this.user.getToken(true).addOnCompleteListener(new OnCompleteListener() { + this.user.getToken(false).addOnCompleteListener(new OnCompleteListener() { @Override public void onComplete(@NonNull Task task) { WritableMap msgMap = Arguments.createMap(); From 86907d5edae77a7f5dcb96937f4db49768c9f888 Mon Sep 17 00:00:00 2001 From: Chaitanya Bhagvan Date: Wed, 23 Nov 2016 17:37:13 +0530 Subject: [PATCH 2/3] Parity of response format --- ios/Firestack/FirestackAuth.m | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/ios/Firestack/FirestackAuth.m b/ios/Firestack/FirestackAuth.m index bcd0919..229c72a 100644 --- a/ios/Firestack/FirestackAuth.m +++ b/ios/Firestack/FirestackAuth.m @@ -29,7 +29,7 @@ @implementation FirestackAuth }; - [self sendJSEvent:AUTH_CHANGED_EVENT + [self sendJSEvent:AUTH_CHANGED_EVENT props: evt]; callBack(@[evt]); @@ -43,7 +43,7 @@ @implementation FirestackAuth @"eventName": AUTH_ANONYMOUS_ERROR_EVENT, @"errorMessage": ex.reason }; - + [self sendJSEvent:AUTH_ERROR_EVENT props:eventError]; NSLog(@"An exception occurred: %@", ex); @@ -186,9 +186,12 @@ @implementation FirestackAuth FIRUser *user = [FIRAuth auth].currentUser; if (user != nil) { - NSMutableDictionary *userProps = [self userPropsFromFIRUser:user]; - [userProps setValue: @((BOOL)true) forKey: @"authenticated"]; - callback(@[[NSNull null], userProps]); + NSDictionary *userProps = [self userPropsFromFIRUser:user]; + NSMutableDictionary *responseProps = @{ + @"authenticated": @((BOOL) true), + @"user": userProps + }; + callback(@[[NSNull null], responseProps]); } else { // No user is signed in. NSDictionary *err = @{ From 363ff1edffb81818d0df9ca973dd46c04ca72438 Mon Sep 17 00:00:00 2001 From: Chaitanya Bhagvan Date: Wed, 23 Nov 2016 17:41:43 +0530 Subject: [PATCH 3/3] Parity of response format --- ios/Firestack/FirestackAuth.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ios/Firestack/FirestackAuth.m b/ios/Firestack/FirestackAuth.m index 229c72a..fac9f41 100644 --- a/ios/Firestack/FirestackAuth.m +++ b/ios/Firestack/FirestackAuth.m @@ -187,7 +187,7 @@ @implementation FirestackAuth if (user != nil) { NSDictionary *userProps = [self userPropsFromFIRUser:user]; - NSMutableDictionary *responseProps = @{ + NSDictionary *responseProps = @{ @"authenticated": @((BOOL) true), @"user": userProps }; @@ -195,6 +195,7 @@ @implementation FirestackAuth } else { // No user is signed in. NSDictionary *err = @{ + @"authenticated": @((BOOL) false), @"user": @"No user logged in" }; callback(@[err]);