aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firebase/Auth/Source/RPCs/FIRAuthBackend.m
diff options
context:
space:
mode:
Diffstat (limited to 'Firebase/Auth/Source/RPCs/FIRAuthBackend.m')
-rw-r--r--Firebase/Auth/Source/RPCs/FIRAuthBackend.m70
1 files changed, 46 insertions, 24 deletions
diff --git a/Firebase/Auth/Source/RPCs/FIRAuthBackend.m b/Firebase/Auth/Source/RPCs/FIRAuthBackend.m
index 0964d3f..0387a1a 100644
--- a/Firebase/Auth/Source/RPCs/FIRAuthBackend.m
+++ b/Firebase/Auth/Source/RPCs/FIRAuthBackend.m
@@ -31,6 +31,8 @@
#import "FIRGetAccountInfoResponse.h"
#import "FIRGetOOBConfirmationCodeRequest.h"
#import "FIRGetOOBConfirmationCodeResponse.h"
+#import "FIRGetProjectConfigRequest.h"
+#import "FIRGetProjectConfigResponse.h"
#import "FIRResetPasswordRequest.h"
#import "FIRResetPasswordResponse.h"
#import "FIRSendVerificationCodeRequest.h"
@@ -398,6 +400,11 @@ static id<FIRAuthBackendImplementation> gBackendImplementation;
[[self implementation] getAccountInfo:request callback:callback];
}
++ (void)getProjectConfig:(FIRGetProjectConfigRequest *)request
+ callback:(FIRGetProjectConfigResponseCallback)callback {
+ [[self implementation] getProjectConfig:request callback:callback];
+}
+
+ (void)setAccountInfo:(FIRSetAccountInfoRequest *)request
callback:(FIRSetAccountInfoResponseCallback)callback {
[[self implementation] setAccountInfo:request callback:callback];
@@ -544,6 +551,18 @@ static id<FIRAuthBackendImplementation> gBackendImplementation;
}];
}
+- (void)getProjectConfig:(FIRGetProjectConfigRequest *)request
+ callback:(FIRGetProjectConfigResponseCallback)callback {
+ FIRGetProjectConfigResponse *response = [[FIRGetProjectConfigResponse alloc] init];
+ [self postWithRequest:request response:response callback:^(NSError *error) {
+ if (error) {
+ callback(nil, error);
+ } else {
+ callback(response, nil);
+ }
+ }];
+}
+
- (void)setAccountInfo:(FIRSetAccountInfoRequest *)request
callback:(FIRSetAccountInfoResponseCallback)callback {
FIRSetAccountInfoResponse *response = [[FIRSetAccountInfoResponse alloc] init];
@@ -713,33 +732,36 @@ static id<FIRAuthBackendImplementation> gBackendImplementation;
response:(id<FIRAuthRPCResponse>)response
callback:(void (^)(NSError *error))callback {
NSError *error;
- id postBody = [request unencodedHTTPRequestBodyWithError:&error];
- if (!postBody) {
- callback([FIRAuthErrorUtils RPCRequestEncodingErrorWithUnderlyingError:error]);
- return;
- }
- NSJSONWritingOptions JSONWritingOptions = 0;
- #if DEBUG
- JSONWritingOptions |= NSJSONWritingPrettyPrinted;
- #endif
-
NSData *bodyData;
- if ([NSJSONSerialization isValidJSONObject:postBody]) {
- bodyData = [NSJSONSerialization dataWithJSONObject:postBody
- options:JSONWritingOptions
- error:&error];
+ if ([request containsPostBody]) {
+ id postBody = [request unencodedHTTPRequestBodyWithError:&error];
+ if (!postBody) {
+ callback([FIRAuthErrorUtils RPCRequestEncodingErrorWithUnderlyingError:error]);
+ return;
+ }
+
+ NSJSONWritingOptions JSONWritingOptions = 0;
+ #if DEBUG
+ JSONWritingOptions |= NSJSONWritingPrettyPrinted;
+ #endif
+
+ if ([NSJSONSerialization isValidJSONObject:postBody]) {
+ bodyData = [NSJSONSerialization dataWithJSONObject:postBody
+ options:JSONWritingOptions
+ error:&error];
+ if (!bodyData) {
+ // This is an untested case. This happens exclusively when there is an error in the framework
+ // implementation of dataWithJSONObject:options:error:. This shouldn't normally occur as
+ // isValidJSONObject: should return NO in any case we should encounter an error.
+ error = [FIRAuthErrorUtils JSONSerializationErrorWithUnderlyingError:error];
+ }
+ } else {
+ error = [FIRAuthErrorUtils JSONSerializationErrorForUnencodableType];
+ }
if (!bodyData) {
- // This is an untested case. This happens exclusively when there is an error in the framework
- // implementation of dataWithJSONObject:options:error:. This shouldn't normally occur as
- // isValidJSONObject: should return NO in any case we should encounter an error.
- error = [FIRAuthErrorUtils JSONSerializationErrorWithUnderlyingError:error];
+ callback(error);
+ return;
}
- } else {
- error = [FIRAuthErrorUtils JSONSerializationErrorForUnencodableType];
- }
- if (!bodyData) {
- callback(error);
- return;
}
[_RPCIssuer asyncPostToURLWithRequestConfiguration:[request requestConfiguration]