Integrations: Fix terms consent display HTTP requests

This commit is contained in:
manuroe 2019-11-15 17:30:21 +01:00
parent 9a58cbccde
commit 46d8947255

View file

@ -522,7 +522,7 @@ NSString *const WidgetManagerErrorDomain = @"WidgetManagerErrorDomain";
MXStrongifyAndReturnIfNil(self); MXStrongifyAndReturnIfNil(self);
// Exchange the token for a scalar token // Exchange the token for a scalar token
MXHTTPClient *httpClient = [[MXHTTPClient alloc] initWithBaseURL:config.apiUrl andOnUnrecognizedCertificateBlock:nil]; __block MXHTTPClient *httpClient = [[MXHTTPClient alloc] initWithBaseURL:config.apiUrl andOnUnrecognizedCertificateBlock:nil];
MXHTTPOperation *operation2 = MXHTTPOperation *operation2 =
[httpClient requestWithMethod:@"POST" [httpClient requestWithMethod:@"POST"
@ -530,6 +530,7 @@ NSString *const WidgetManagerErrorDomain = @"WidgetManagerErrorDomain";
parameters:tokenObject.JSONDictionary parameters:tokenObject.JSONDictionary
success:^(NSDictionary *JSONResponse) success:^(NSDictionary *JSONResponse)
{ {
httpClient = nil;
NSString *scalarToken; NSString *scalarToken;
MXJSONModelSetString(scalarToken, JSONResponse[@"scalar_token"]) MXJSONModelSetString(scalarToken, JSONResponse[@"scalar_token"])
@ -551,6 +552,8 @@ NSString *const WidgetManagerErrorDomain = @"WidgetManagerErrorDomain";
[operation mutateTo:operation3]; [operation mutateTo:operation3];
} failure:^(NSError *error) { } failure:^(NSError *error) {
httpClient = nil;
NSLog(@"[WidgetManager] registerForScalarToken: Failed to register. Error: %@", error); NSLog(@"[WidgetManager] registerForScalarToken: Failed to register. Error: %@", error);
if (failure) if (failure)
@ -594,12 +597,13 @@ NSString *const WidgetManagerErrorDomain = @"WidgetManagerErrorDomain";
return nil; return nil;
} }
MXHTTPClient *httpClient = [[MXHTTPClient alloc] initWithBaseURL:config.apiUrl andOnUnrecognizedCertificateBlock:nil]; __block MXHTTPClient *httpClient = [[MXHTTPClient alloc] initWithBaseURL:config.apiUrl andOnUnrecognizedCertificateBlock:nil];
return [httpClient requestWithMethod:@"GET" return [httpClient requestWithMethod:@"GET"
path:[NSString stringWithFormat:@"account?v=1.1&scalar_token=%@", scalarToken] path:[NSString stringWithFormat:@"account?v=1.1&scalar_token=%@", scalarToken]
parameters:nil parameters:nil
success:^(NSDictionary *JSONResponse) { success:^(NSDictionary *JSONResponse) {
httpClient = nil;
NSString *userId; NSString *userId;
MXJSONModelSetString(userId, JSONResponse[@"user_id"]) MXJSONModelSetString(userId, JSONResponse[@"user_id"])
@ -615,6 +619,8 @@ NSString *const WidgetManagerErrorDomain = @"WidgetManagerErrorDomain";
} }
} failure:^(NSError *error) { } failure:^(NSError *error) {
httpClient = nil;
NSHTTPURLResponse *urlResponse = [MXHTTPOperation urlResponseFromError:error]; NSHTTPURLResponse *urlResponse = [MXHTTPOperation urlResponseFromError:error];
NSLog(@"[WidgetManager] validateScalarToken. Error in modular/account request. statusCode: %@", @(urlResponse.statusCode)); NSLog(@"[WidgetManager] validateScalarToken. Error in modular/account request. statusCode: %@", @(urlResponse.statusCode));