Showing
2 changed files
with
19 additions
and
2 deletions
| ... | @@ -684,7 +684,7 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -684,7 +684,7 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
| 684 | if (failure) { | 684 | if (failure) { |
| 685 | if ([error isEqual:@{@"code": @401}]) { | 685 | if ([error isEqual:@{@"code": @401}]) { |
| 686 | [self refreshToken:^(NSDictionary *response) { | 686 | [self refreshToken:^(NSDictionary *response) { |
| 687 | -// [_db executeUpdate:@"INSERT INTO requestVariables (access_token, refresh_token) VALUES (?, ?)", [response objectForKey:@"access_token"], [response objectForKey:@"refresh_token"]]; | 687 | +// [_db executeUpdate:@"UPDATE requestVariables SET access_token = ?, refresh_token = ? WHERE id = 1", [response objectForKey:@"access_token"], [response objectForKey:@"refresh_token"]]; |
| 688 | NSDictionary *successResponse = @{@"result": @"success", @"status":@1}; | 688 | NSDictionary *successResponse = @{@"result": @"success", @"status":@1}; |
| 689 | success(successResponse); | 689 | success(successResponse); |
| 690 | } failureBlock:^(NSError *error) { | 690 | } failureBlock:^(NSError *error) { |
| ... | @@ -726,7 +726,24 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -726,7 +726,24 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
| 726 | } | 726 | } |
| 727 | } failureBlock:^(NSError *error) { | 727 | } failureBlock:^(NSError *error) { |
| 728 | if (failure) { | 728 | if (failure) { |
| 729 | - failure(error); | 729 | + if ([error isEqual:@{@"code": @401}]) { |
| 730 | + [self refreshToken:^(NSDictionary *response) { | ||
| 731 | + [self sendContext8:jsonData successBlock:^(NSDictionary *contextResponse) { | ||
| 732 | + if (success) { | ||
| 733 | + success(contextResponse); | ||
| 734 | + } | ||
| 735 | + } failureBlock:^(NSError *error) { | ||
| 736 | + if (failure) { | ||
| 737 | + failure(error); | ||
| 738 | + } | ||
| 739 | + }]; | ||
| 740 | + } failureBlock:^(NSError *error) { | ||
| 741 | + if (failure) { | ||
| 742 | + [_db executeUpdate:@"DROP TABLE requestVariables"]; | ||
| 743 | + failure(error); | ||
| 744 | + } | ||
| 745 | + NSLog(@"Error at token %@", error ); | ||
| 746 | + }]; | ||
| 730 | } | 747 | } |
| 731 | NSLog(@"Error at get profile %@", error ); | 748 | NSLog(@"Error at get profile %@", error ); |
| 732 | }]; | 749 | }]; | ... | ... |
-
Please register or login to post a comment