Manos Chorianopoulos

fix refreshToken crash

......@@ -932,6 +932,7 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
- (void)refreshToken:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure
{
if ([_db tableExists:@"requestVariables"] == YES) {
FMResultSet *refreshTokenSet = [_db executeQuery:@"SELECT refresh_token FROM requestVariables WHERE id = 1;"];
NSString *refreshToken = [NSString alloc];
while ([refreshTokenSet next]) {
......@@ -963,7 +964,7 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
NSString* errorCode = [dict objectForKey:@"NSLocalizedDescription"];
if ([errorCode isEqual:@"Request failed: unauthorized (401)"]) {
[self refreshToken2ndTry:^(NSDictionary *response) {
// [_db executeUpdate:@"UPDATE requestVariables SET access_token = ?, refresh_token = ? WHERE id = 1", [response objectForKey:@"access_token"], [response objectForKey:@"refresh_token"]];
// [_db executeUpdate:@"UPDATE requestVariables SET access_token = ?, refresh_token = ? WHERE id = 1", [response objectForKey:@"access_token"], [response objectForKey:@"refresh_token"]];
NSDictionary *successResponse = @{@"result": @"success", @"status":@1};
success(successResponse);
} failureBlock:^(NSError *error) {
......@@ -977,6 +978,7 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
NSLog(@"Error at token %@", error );
}
}];
}
}
- (void)refreshToken2ndTry:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure
......