Manos Chorianopoulos

fix db error

......@@ -1168,10 +1168,26 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
NSDictionary *postDictionary3 = @{@"client_id": clientId, @"client_secret": clientSecret, @"refresh_token": refreshToken, @"grant_type":@"refresh_token", };
NSData *jsonData3 = [NSJSONSerialization dataWithJSONObject:postDictionary3 options:0 error:NULL];
[self sendContext5:jsonData3 successBlock:^(NSDictionary *contextResponse) {
if (success) {
[_db executeUpdate:@"UPDATE requestVariables SET access_token = ?, refresh_token = ? WHERE id = 1", [contextResponse objectForKey:@"access_token"], [contextResponse objectForKey:@"refresh_token"]];
NSDictionary *successResponse = @{@"result": @"success", @"status":@1};
success(successResponse);
if (success && ([_db tableExists:@"requestVariables"] == YES)) {
// [_db executeUpdate:@"UPDATE requestVariables SET access_token = ?, refresh_token = ? WHERE id = 1", [contextResponse objectForKey:@"access_token"], [contextResponse objectForKey:@"refresh_token"]];
// NSDictionary *successResponse = @{@"result": @"success", @"status":@1};
// success(successResponse);
@try {
[_db executeUpdate:@"UPDATE requestVariables SET access_token = ?, refresh_token = ? WHERE id = 1", [contextResponse objectForKey:@"access_token"], [contextResponse objectForKey:@"refresh_token"]];
NSDictionary *successResponse = @{@"result": @"success", @"status":@1};
success(successResponse);
}
@catch (NSException *exception) {
NSLog(@"UPDATE Token error: %@", exception.reason);
if (failure) {
NSError *error = nil;
failure(error);
}
}
@finally {
// NSLog(@"Finally condition");
}
}
} failureBlock:^(NSError *error) {
if (failure) {
......@@ -1239,10 +1255,26 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
NSDictionary *postDictionary3 = @{@"client_id": clientId, @"client_secret": clientSecret, @"refresh_token": refreshToken, @"grant_type":@"refresh_token", };
NSData *jsonData3 = [NSJSONSerialization dataWithJSONObject:postDictionary3 options:0 error:NULL];
[self sendContext5:jsonData3 successBlock:^(NSDictionary *contextResponse) {
if (success) {
[_db executeUpdate:@"UPDATE requestVariables SET access_token = ?, refresh_token = ? WHERE id = 1", [contextResponse objectForKey:@"access_token"], [contextResponse objectForKey:@"refresh_token"]];
NSDictionary *successResponse = @{@"result": @"success", @"status":@1};
success(successResponse);
if (success && ([_db tableExists:@"requestVariables"] == YES)) {
// [_db executeUpdate:@"UPDATE requestVariables SET access_token = ?, refresh_token = ? WHERE id = 1", [contextResponse objectForKey:@"access_token"], [contextResponse objectForKey:@"refresh_token"]];
// NSDictionary *successResponse = @{@"result": @"success", @"status":@1};
// success(successResponse);
@try {
[_db executeUpdate:@"UPDATE requestVariables SET access_token = ?, refresh_token = ? WHERE id = 1", [contextResponse objectForKey:@"access_token"], [contextResponse objectForKey:@"refresh_token"]];
NSDictionary *successResponse = @{@"result": @"success", @"status":@1};
success(successResponse);
}
@catch (NSException *exception) {
NSLog(@"UPDATE Token error: %@", exception.reason);
if (failure) {
NSError *error = nil;
failure(error);
}
}
@finally {
// NSLog(@"Finally condition");
}
}
} failureBlock:^(NSError *error) {
if (failure) {
......@@ -1310,10 +1342,26 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
NSDictionary *postDictionary3 = @{@"client_id": clientId, @"client_secret": clientSecret, @"refresh_token": refreshToken, @"grant_type":@"refresh_token", };
NSData *jsonData3 = [NSJSONSerialization dataWithJSONObject:postDictionary3 options:0 error:NULL];
[self sendContext5:jsonData3 successBlock:^(NSDictionary *contextResponse) {
if (success) {
[_db executeUpdate:@"UPDATE requestVariables SET access_token = ?, refresh_token = ? WHERE id = 1", [contextResponse objectForKey:@"access_token"], [contextResponse objectForKey:@"refresh_token"]];
NSDictionary *successResponse = @{@"result": @"success", @"status":@1};
success(successResponse);
if (success && ([_db tableExists:@"requestVariables"] == YES)) {
// [_db executeUpdate:@"UPDATE requestVariables SET access_token = ?, refresh_token = ? WHERE id = 1", [contextResponse objectForKey:@"access_token"], [contextResponse objectForKey:@"refresh_token"]];
// NSDictionary *successResponse = @{@"result": @"success", @"status":@1};
// success(successResponse);
@try {
[_db executeUpdate:@"UPDATE requestVariables SET access_token = ?, refresh_token = ? WHERE id = 1", [contextResponse objectForKey:@"access_token"], [contextResponse objectForKey:@"refresh_token"]];
NSDictionary *successResponse = @{@"result": @"success", @"status":@1};
success(successResponse);
}
@catch (NSException *exception) {
NSLog(@"UPDATE Token error: %@", exception.reason);
if (failure) {
NSError *error = nil;
failure(error);
}
}
@finally {
// NSLog(@"Finally condition");
}
}
} failureBlock:^(NSError *error) {
if (failure) {
......