Showing
2 changed files
with
260 additions
and
2 deletions
... | @@ -682,7 +682,10 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -682,7 +682,10 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
682 | } | 682 | } |
683 | } failureBlock:^(NSError *error) { | 683 | } failureBlock:^(NSError *error) { |
684 | if (failure) { | 684 | if (failure) { |
685 | - if ([error isEqual:@{@"code": @401}]) { | 685 | + NSDictionary* dict = [NSDictionary alloc]; |
686 | + dict = [error userInfo]; | ||
687 | + NSString* errorCode = [dict objectForKey:@"NSLocalizedDescription"]; | ||
688 | + if ([errorCode isEqual:@"Request failed: unauthorized (401)"]) { | ||
686 | [self refreshToken:^(NSDictionary *response) { | 689 | [self refreshToken:^(NSDictionary *response) { |
687 | // [_db executeUpdate:@"UPDATE requestVariables SET access_token = ?, refresh_token = ? WHERE id = 1", [response objectForKey:@"access_token"], [response objectForKey:@"refresh_token"]]; | 690 | // [_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}; | 691 | NSDictionary *successResponse = @{@"result": @"success", @"status":@1}; |
... | @@ -726,7 +729,10 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -726,7 +729,10 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
726 | } | 729 | } |
727 | } failureBlock:^(NSError *error) { | 730 | } failureBlock:^(NSError *error) { |
728 | if (failure) { | 731 | if (failure) { |
729 | - if ([error isEqual:@{@"code": @401}]) { | 732 | + NSDictionary* dict = [NSDictionary alloc]; |
733 | + dict = [error userInfo]; | ||
734 | + NSString* errorCode = [dict objectForKey:@"NSLocalizedDescription"]; | ||
735 | + if ([errorCode isEqual:@"Request failed: unauthorized (401)"]) { | ||
730 | [self refreshToken:^(NSDictionary *response) { | 736 | [self refreshToken:^(NSDictionary *response) { |
731 | [self sendContext8:jsonData successBlock:^(NSDictionary *contextResponse) { | 737 | [self sendContext8:jsonData successBlock:^(NSDictionary *contextResponse) { |
732 | if (success) { | 738 | if (success) { |
... | @@ -824,9 +830,30 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -824,9 +830,30 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
824 | } | 830 | } |
825 | } failureBlock:^(NSError *error) { | 831 | } failureBlock:^(NSError *error) { |
826 | if (failure) { | 832 | if (failure) { |
833 | + NSDictionary* dict = [NSDictionary alloc]; | ||
834 | + dict = [error userInfo]; | ||
835 | + NSString* errorCode = [dict objectForKey:@"NSLocalizedDescription"]; | ||
836 | + if ([errorCode isEqual:@"Request failed: unauthorized (401)"]) { | ||
837 | + [self refreshToken:^(NSDictionary *response) { | ||
838 | + [self sendContext8:jsonData successBlock:^(NSDictionary *contextResponse) { | ||
839 | + if (success) { | ||
840 | + success(contextResponse); | ||
841 | + } | ||
842 | + } failureBlock:^(NSError *error) { | ||
843 | + if (failure) { | ||
844 | + failure(error); | ||
845 | + } | ||
846 | + }]; | ||
847 | + } failureBlock:^(NSError *error) { | ||
848 | + if (failure) { | ||
849 | + [_db executeUpdate:@"DROP TABLE requestVariables"]; | ||
827 | failure(error); | 850 | failure(error); |
828 | } | 851 | } |
852 | + NSLog(@"Error at token %@", error ); | ||
853 | + }]; | ||
854 | + } | ||
829 | NSLog(@"Error at edit profile %@", error ); | 855 | NSLog(@"Error at edit profile %@", error ); |
856 | + } | ||
830 | }]; | 857 | }]; |
831 | } | 858 | } |
832 | 859 | ||
... | @@ -840,9 +867,30 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -840,9 +867,30 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
840 | } | 867 | } |
841 | } failureBlock:^(NSError *error) { | 868 | } failureBlock:^(NSError *error) { |
842 | if (failure) { | 869 | if (failure) { |
870 | + NSDictionary* dict = [NSDictionary alloc]; | ||
871 | + dict = [error userInfo]; | ||
872 | + NSString* errorCode = [dict objectForKey:@"NSLocalizedDescription"]; | ||
873 | + if ([errorCode isEqual:@"Request failed: unauthorized (401)"]) { | ||
874 | + [self refreshToken:^(NSDictionary *response) { | ||
875 | + [self sendContext8:jsonData successBlock:^(NSDictionary *contextResponse) { | ||
876 | + if (success) { | ||
877 | + success(contextResponse); | ||
878 | + } | ||
879 | + } failureBlock:^(NSError *error) { | ||
880 | + if (failure) { | ||
843 | failure(error); | 881 | failure(error); |
844 | } | 882 | } |
883 | + }]; | ||
884 | + } failureBlock:^(NSError *error) { | ||
885 | + if (failure) { | ||
886 | + [_db executeUpdate:@"DROP TABLE requestVariables"]; | ||
887 | + failure(error); | ||
888 | + } | ||
889 | + NSLog(@"Error at token %@", error ); | ||
890 | + }]; | ||
891 | + } | ||
845 | NSLog(@"Error at change profile image %@", error ); | 892 | NSLog(@"Error at change profile image %@", error ); |
893 | + } | ||
846 | }]; | 894 | }]; |
847 | } | 895 | } |
848 | 896 | ||
... | @@ -856,9 +904,30 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -856,9 +904,30 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
856 | } | 904 | } |
857 | } failureBlock:^(NSError *error) { | 905 | } failureBlock:^(NSError *error) { |
858 | if (failure) { | 906 | if (failure) { |
907 | + NSDictionary* dict = [NSDictionary alloc]; | ||
908 | + dict = [error userInfo]; | ||
909 | + NSString* errorCode = [dict objectForKey:@"NSLocalizedDescription"]; | ||
910 | + if ([errorCode isEqual:@"Request failed: unauthorized (401)"]) { | ||
911 | + [self refreshToken:^(NSDictionary *response) { | ||
912 | + [self sendContext8:jsonData successBlock:^(NSDictionary *contextResponse) { | ||
913 | + if (success) { | ||
914 | + success(contextResponse); | ||
915 | + } | ||
916 | + } failureBlock:^(NSError *error) { | ||
917 | + if (failure) { | ||
918 | + failure(error); | ||
919 | + } | ||
920 | + }]; | ||
921 | + } failureBlock:^(NSError *error) { | ||
922 | + if (failure) { | ||
923 | + [_db executeUpdate:@"DROP TABLE requestVariables"]; | ||
859 | failure(error); | 924 | failure(error); |
860 | } | 925 | } |
926 | + NSLog(@"Error at token %@", error ); | ||
927 | + }]; | ||
928 | + } | ||
861 | NSLog(@"Error at add card %@", error ); | 929 | NSLog(@"Error at add card %@", error ); |
930 | + } | ||
862 | }]; | 931 | }]; |
863 | } | 932 | } |
864 | 933 | ||
... | @@ -872,9 +941,30 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -872,9 +941,30 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
872 | } | 941 | } |
873 | } failureBlock:^(NSError *error) { | 942 | } failureBlock:^(NSError *error) { |
874 | if (failure) { | 943 | if (failure) { |
944 | + NSDictionary* dict = [NSDictionary alloc]; | ||
945 | + dict = [error userInfo]; | ||
946 | + NSString* errorCode = [dict objectForKey:@"NSLocalizedDescription"]; | ||
947 | + if ([errorCode isEqual:@"Request failed: unauthorized (401)"]) { | ||
948 | + [self refreshToken:^(NSDictionary *response) { | ||
949 | + [self sendContext8:jsonData successBlock:^(NSDictionary *contextResponse) { | ||
950 | + if (success) { | ||
951 | + success(contextResponse); | ||
952 | + } | ||
953 | + } failureBlock:^(NSError *error) { | ||
954 | + if (failure) { | ||
955 | + failure(error); | ||
956 | + } | ||
957 | + }]; | ||
958 | + } failureBlock:^(NSError *error) { | ||
959 | + if (failure) { | ||
960 | + [_db executeUpdate:@"DROP TABLE requestVariables"]; | ||
875 | failure(error); | 961 | failure(error); |
876 | } | 962 | } |
963 | + NSLog(@"Error at token %@", error ); | ||
964 | + }]; | ||
965 | + } | ||
877 | NSLog(@"Error at get cards %@", error ); | 966 | NSLog(@"Error at get cards %@", error ); |
967 | + } | ||
878 | }]; | 968 | }]; |
879 | } | 969 | } |
880 | 970 | ||
... | @@ -888,9 +978,30 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -888,9 +978,30 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
888 | } | 978 | } |
889 | } failureBlock:^(NSError *error) { | 979 | } failureBlock:^(NSError *error) { |
890 | if (failure) { | 980 | if (failure) { |
981 | + NSDictionary* dict = [NSDictionary alloc]; | ||
982 | + dict = [error userInfo]; | ||
983 | + NSString* errorCode = [dict objectForKey:@"NSLocalizedDescription"]; | ||
984 | + if ([errorCode isEqual:@"Request failed: unauthorized (401)"]) { | ||
985 | + [self refreshToken:^(NSDictionary *response) { | ||
986 | + [self sendContext8:jsonData successBlock:^(NSDictionary *contextResponse) { | ||
987 | + if (success) { | ||
988 | + success(contextResponse); | ||
989 | + } | ||
990 | + } failureBlock:^(NSError *error) { | ||
991 | + if (failure) { | ||
891 | failure(error); | 992 | failure(error); |
892 | } | 993 | } |
994 | + }]; | ||
995 | + } failureBlock:^(NSError *error) { | ||
996 | + if (failure) { | ||
997 | + [_db executeUpdate:@"DROP TABLE requestVariables"]; | ||
998 | + failure(error); | ||
999 | + } | ||
1000 | + NSLog(@"Error at token %@", error ); | ||
1001 | + }]; | ||
1002 | + } | ||
893 | NSLog(@"Error at get cards %@", error ); | 1003 | NSLog(@"Error at get cards %@", error ); |
1004 | + } | ||
894 | }]; | 1005 | }]; |
895 | } | 1006 | } |
896 | 1007 | ||
... | @@ -939,9 +1050,30 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -939,9 +1050,30 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
939 | } | 1050 | } |
940 | } failureBlock:^(NSError *error) { | 1051 | } failureBlock:^(NSError *error) { |
941 | if (failure) { | 1052 | if (failure) { |
1053 | + NSDictionary* dict = [NSDictionary alloc]; | ||
1054 | + dict = [error userInfo]; | ||
1055 | + NSString* errorCode = [dict objectForKey:@"NSLocalizedDescription"]; | ||
1056 | + if ([errorCode isEqual:@"Request failed: unauthorized (401)"]) { | ||
1057 | + [self refreshToken:^(NSDictionary *response) { | ||
1058 | + [self sendContext8:jsonData successBlock:^(NSDictionary *contextResponse) { | ||
1059 | + if (success) { | ||
1060 | + success(contextResponse); | ||
1061 | + } | ||
1062 | + } failureBlock:^(NSError *error) { | ||
1063 | + if (failure) { | ||
1064 | + failure(error); | ||
1065 | + } | ||
1066 | + }]; | ||
1067 | + } failureBlock:^(NSError *error) { | ||
1068 | + if (failure) { | ||
1069 | + [_db executeUpdate:@"DROP TABLE requestVariables"]; | ||
942 | failure(error); | 1070 | failure(error); |
943 | } | 1071 | } |
1072 | + NSLog(@"Error at token %@", error ); | ||
1073 | + }]; | ||
1074 | + } | ||
944 | NSLog(@"Error at get cards %@", error ); | 1075 | NSLog(@"Error at get cards %@", error ); |
1076 | + } | ||
945 | }]; | 1077 | }]; |
946 | } | 1078 | } |
947 | 1079 | ||
... | @@ -955,9 +1087,30 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -955,9 +1087,30 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
955 | } | 1087 | } |
956 | } failureBlock:^(NSError *error) { | 1088 | } failureBlock:^(NSError *error) { |
957 | if (failure) { | 1089 | if (failure) { |
1090 | + NSDictionary* dict = [NSDictionary alloc]; | ||
1091 | + dict = [error userInfo]; | ||
1092 | + NSString* errorCode = [dict objectForKey:@"NSLocalizedDescription"]; | ||
1093 | + if ([errorCode isEqual:@"Request failed: unauthorized (401)"]) { | ||
1094 | + [self refreshToken:^(NSDictionary *response) { | ||
1095 | + [self sendContext8:jsonData successBlock:^(NSDictionary *contextResponse) { | ||
1096 | + if (success) { | ||
1097 | + success(contextResponse); | ||
1098 | + } | ||
1099 | + } failureBlock:^(NSError *error) { | ||
1100 | + if (failure) { | ||
1101 | + failure(error); | ||
1102 | + } | ||
1103 | + }]; | ||
1104 | + } failureBlock:^(NSError *error) { | ||
1105 | + if (failure) { | ||
1106 | + [_db executeUpdate:@"DROP TABLE requestVariables"]; | ||
958 | failure(error); | 1107 | failure(error); |
959 | } | 1108 | } |
1109 | + NSLog(@"Error at token %@", error ); | ||
1110 | + }]; | ||
1111 | + } | ||
960 | NSLog(@"Error at get cards %@", error ); | 1112 | NSLog(@"Error at get cards %@", error ); |
1113 | + } | ||
961 | }]; | 1114 | }]; |
962 | } | 1115 | } |
963 | 1116 | ||
... | @@ -971,9 +1124,30 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -971,9 +1124,30 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
971 | } | 1124 | } |
972 | } failureBlock:^(NSError *error) { | 1125 | } failureBlock:^(NSError *error) { |
973 | if (failure) { | 1126 | if (failure) { |
1127 | + NSDictionary* dict = [NSDictionary alloc]; | ||
1128 | + dict = [error userInfo]; | ||
1129 | + NSString* errorCode = [dict objectForKey:@"NSLocalizedDescription"]; | ||
1130 | + if ([errorCode isEqual:@"Request failed: unauthorized (401)"]) { | ||
1131 | + [self refreshToken:^(NSDictionary *response) { | ||
1132 | + [self sendContext8:jsonData successBlock:^(NSDictionary *contextResponse) { | ||
1133 | + if (success) { | ||
1134 | + success(contextResponse); | ||
1135 | + } | ||
1136 | + } failureBlock:^(NSError *error) { | ||
1137 | + if (failure) { | ||
974 | failure(error); | 1138 | failure(error); |
975 | } | 1139 | } |
1140 | + }]; | ||
1141 | + } failureBlock:^(NSError *error) { | ||
1142 | + if (failure) { | ||
1143 | + [_db executeUpdate:@"DROP TABLE requestVariables"]; | ||
1144 | + failure(error); | ||
1145 | + } | ||
1146 | + NSLog(@"Error at token %@", error ); | ||
1147 | + }]; | ||
1148 | + } | ||
976 | NSLog(@"Error at get cards %@", error ); | 1149 | NSLog(@"Error at get cards %@", error ); |
1150 | + } | ||
977 | }]; | 1151 | }]; |
978 | } | 1152 | } |
979 | 1153 | ||
... | @@ -987,9 +1161,30 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -987,9 +1161,30 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
987 | } | 1161 | } |
988 | } failureBlock:^(NSError *error) { | 1162 | } failureBlock:^(NSError *error) { |
989 | if (failure) { | 1163 | if (failure) { |
1164 | + NSDictionary* dict = [NSDictionary alloc]; | ||
1165 | + dict = [error userInfo]; | ||
1166 | + NSString* errorCode = [dict objectForKey:@"NSLocalizedDescription"]; | ||
1167 | + if ([errorCode isEqual:@"Request failed: unauthorized (401)"]) { | ||
1168 | + [self refreshToken:^(NSDictionary *response) { | ||
1169 | + [self sendContext8:jsonData successBlock:^(NSDictionary *contextResponse) { | ||
1170 | + if (success) { | ||
1171 | + success(contextResponse); | ||
1172 | + } | ||
1173 | + } failureBlock:^(NSError *error) { | ||
1174 | + if (failure) { | ||
1175 | + failure(error); | ||
1176 | + } | ||
1177 | + }]; | ||
1178 | + } failureBlock:^(NSError *error) { | ||
1179 | + if (failure) { | ||
1180 | + [_db executeUpdate:@"DROP TABLE requestVariables"]; | ||
990 | failure(error); | 1181 | failure(error); |
991 | } | 1182 | } |
1183 | + NSLog(@"Error at token %@", error ); | ||
1184 | + }]; | ||
1185 | + } | ||
992 | NSLog(@"Error at get cards %@", error ); | 1186 | NSLog(@"Error at get cards %@", error ); |
1187 | + } | ||
993 | }]; | 1188 | }]; |
994 | } | 1189 | } |
995 | 1190 | ||
... | @@ -1003,9 +1198,30 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -1003,9 +1198,30 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
1003 | } | 1198 | } |
1004 | } failureBlock:^(NSError *error) { | 1199 | } failureBlock:^(NSError *error) { |
1005 | if (failure) { | 1200 | if (failure) { |
1201 | + NSDictionary* dict = [NSDictionary alloc]; | ||
1202 | + dict = [error userInfo]; | ||
1203 | + NSString* errorCode = [dict objectForKey:@"NSLocalizedDescription"]; | ||
1204 | + if ([errorCode isEqual:@"Request failed: unauthorized (401)"]) { | ||
1205 | + [self refreshToken:^(NSDictionary *response) { | ||
1206 | + [self sendContext8:jsonData successBlock:^(NSDictionary *contextResponse) { | ||
1207 | + if (success) { | ||
1208 | + success(contextResponse); | ||
1209 | + } | ||
1210 | + } failureBlock:^(NSError *error) { | ||
1211 | + if (failure) { | ||
1212 | + failure(error); | ||
1213 | + } | ||
1214 | + }]; | ||
1215 | + } failureBlock:^(NSError *error) { | ||
1216 | + if (failure) { | ||
1217 | + [_db executeUpdate:@"DROP TABLE requestVariables"]; | ||
1006 | failure(error); | 1218 | failure(error); |
1007 | } | 1219 | } |
1220 | + NSLog(@"Error at token %@", error ); | ||
1221 | + }]; | ||
1222 | + } | ||
1008 | NSLog(@"Error at get cards %@", error ); | 1223 | NSLog(@"Error at get cards %@", error ); |
1224 | + } | ||
1009 | }]; | 1225 | }]; |
1010 | } | 1226 | } |
1011 | 1227 | ||
... | @@ -1064,9 +1280,30 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -1064,9 +1280,30 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
1064 | } | 1280 | } |
1065 | } failureBlock:^(NSError *error) { | 1281 | } failureBlock:^(NSError *error) { |
1066 | if (failure) { | 1282 | if (failure) { |
1283 | + NSDictionary* dict = [NSDictionary alloc]; | ||
1284 | + dict = [error userInfo]; | ||
1285 | + NSString* errorCode = [dict objectForKey:@"NSLocalizedDescription"]; | ||
1286 | + if ([errorCode isEqual:@"Request failed: unauthorized (401)"]) { | ||
1287 | + [self refreshToken:^(NSDictionary *response) { | ||
1288 | + [self sendContext8:jsonData successBlock:^(NSDictionary *contextResponse) { | ||
1289 | + if (success) { | ||
1290 | + success(contextResponse); | ||
1291 | + } | ||
1292 | + } failureBlock:^(NSError *error) { | ||
1293 | + if (failure) { | ||
1067 | failure(error); | 1294 | failure(error); |
1068 | } | 1295 | } |
1296 | + }]; | ||
1297 | + } failureBlock:^(NSError *error) { | ||
1298 | + if (failure) { | ||
1299 | + [_db executeUpdate:@"DROP TABLE requestVariables"]; | ||
1300 | + failure(error); | ||
1301 | + } | ||
1302 | + NSLog(@"Error at token %@", error ); | ||
1303 | + }]; | ||
1304 | + } | ||
1069 | NSLog(@"Error at edit profile %@", error ); | 1305 | NSLog(@"Error at edit profile %@", error ); |
1306 | + } | ||
1070 | }]; | 1307 | }]; |
1071 | } | 1308 | } |
1072 | 1309 | ||
... | @@ -1096,9 +1333,30 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -1096,9 +1333,30 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
1096 | } | 1333 | } |
1097 | } failureBlock:^(NSError *error) { | 1334 | } failureBlock:^(NSError *error) { |
1098 | if (failure) { | 1335 | if (failure) { |
1336 | + NSDictionary* dict = [NSDictionary alloc]; | ||
1337 | + dict = [error userInfo]; | ||
1338 | + NSString* errorCode = [dict objectForKey:@"NSLocalizedDescription"]; | ||
1339 | + if ([errorCode isEqual:@"Request failed: unauthorized (401)"]) { | ||
1340 | + [self refreshToken:^(NSDictionary *response) { | ||
1341 | + [self sendContext8:jsonData successBlock:^(NSDictionary *contextResponse) { | ||
1342 | + if (success) { | ||
1343 | + success(contextResponse); | ||
1344 | + } | ||
1345 | + } failureBlock:^(NSError *error) { | ||
1346 | + if (failure) { | ||
1347 | + failure(error); | ||
1348 | + } | ||
1349 | + }]; | ||
1350 | + } failureBlock:^(NSError *error) { | ||
1351 | + if (failure) { | ||
1352 | + [_db executeUpdate:@"DROP TABLE requestVariables"]; | ||
1099 | failure(error); | 1353 | failure(error); |
1100 | } | 1354 | } |
1355 | + NSLog(@"Error at token %@", error ); | ||
1356 | + }]; | ||
1357 | + } | ||
1101 | NSLog(@"Error at get cards %@", error ); | 1358 | NSLog(@"Error at get cards %@", error ); |
1359 | + } | ||
1102 | }]; | 1360 | }]; |
1103 | } | 1361 | } |
1104 | 1362 | ... | ... |
-
Please register or login to post a comment