Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5b7de35

Browse files
Maintain similar response format for getCurrentUser and signInWith*
1 parent 266f9c3 commit 5b7de35

File tree

1 file changed

+25
-12
lines changed

1 file changed

+25
-12
lines changed

‎ios/Firestack/FirestackAuth.m‎

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ @implementation FirestackAuth
1717
RCT_EXPORT_MODULE(FirestackAuth);
1818

1919
RCT_EXPORT_METHOD(signInAnonymously:
20-
(RCTResponseSenderBlock) callBack)
20+
(RCTResponseSenderBlock) callback)
2121
{
2222
@try {
2323
[[FIRAuth auth] signInAnonymouslyWithCompletion
@@ -32,10 +32,14 @@ @implementation FirestackAuth
3232
[self sendJSEvent:AUTH_CHANGED_EVENT
3333
props: evt];
3434

35-
callBack(@[evt]);
35+
callback(@[evt]);
3636
} else {
37-
NSDictionary *userProps = [self userPropsFromFIRUser:user];
38-
callBack(@[[NSNull null], userProps]);
37+
NSDictionary *userProps = [self userPropsFromFIRUser:user];
38+
NSDictionary *responseProps = @{
39+
@"authenticated": @((BOOL) true),
40+
@"user": userProps
41+
};
42+
callback(@[[NSNull null], responseProps]);
3943
}
4044
}];
4145
} @catch(NSException *ex) {
@@ -47,7 +51,7 @@ @implementation FirestackAuth
4751
[self sendJSEvent:AUTH_ERROR_EVENT
4852
props:eventError];
4953
NSLog(@"An exception occurred: %@", ex);
50-
callBack(@[eventError]);
54+
callback(@[eventError]);
5155
}
5256
}
5357

@@ -61,7 +65,11 @@ @implementation FirestackAuth
6165

6266
if (user != nil) {
6367
NSDictionary *userProps = [self userPropsFromFIRUser:user];
64-
callback(@[[NSNull null], userProps]);
68+
NSDictionary *responseProps = @{
69+
@"authenticated": @((BOOL) true),
70+
@"user": userProps
71+
};
72+
callback(@[[NSNull null], responseProps]);
6573
} else {
6674
NSDictionary *err =
6775
[FirestackErrors handleFirebaseError:AUTH_ERROR_EVENT
@@ -94,7 +102,11 @@ @implementation FirestackAuth
94102
if (user != nil) {
95103
// User is signed in.
96104
NSDictionary *userProps = [self userPropsFromFIRUser:user];
97-
callback(@[[NSNull null], userProps]);
105+
NSDictionary *responseProps = @{
106+
@"authenticated": @((BOOL) true),
107+
@"user": userProps
108+
};
109+
callback(@[[NSNull null], responseProps]);
98110
} else {
99111
NSLog(@"An error occurred: %@", [error localizedDescription]);
100112
NSLog(@"[Error signInWithProvider]: %@", [error userInfo]);
@@ -146,7 +158,7 @@ @implementation FirestackAuth
146158
sendJSEvent:AUTH_CHANGED_EVENT
147159
props: @{
148160
@"eventName": @"userTokenError",
149-
@"authenticated": @((BOOL)true),
161+
@"authenticated": @((BOOL)false),
150162
@"errorMessage": [error localizedFailureReason]
151163
}];
152164
} else {
@@ -236,10 +248,11 @@ @implementation FirestackAuth
236248
completion:^(FIRUser *user, NSError *error) {
237249
if (user != nil) {
238250
NSDictionary *userProps = [self userPropsFromFIRUser:user];
239-
240-
callback(@[[NSNull null], @{
241-
@"user": userProps
242-
}]);
251+
NSDictionary *responseProps = @{
252+
@"authenticated": @((BOOL) true),
253+
@"user": userProps
254+
};
255+
callback(@[[NSNull null], responseProps]);
243256
} else {
244257
NSDictionary *err =
245258
[FirestackErrors handleFirebaseError:@"signinError"

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /