Vasilis

fixes at getProfile(embed refreshToken)

......@@ -684,7 +684,7 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
if (failure) {
if ([error isEqual:@{@"code": @401}]) {
[self refreshToken:^(NSDictionary *response) {
// [_db executeUpdate:@"INSERT INTO requestVariables (access_token, refresh_token) VALUES (?, ?)", [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) {
......@@ -726,8 +726,25 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
}
} failureBlock:^(NSError *error) {
if (failure) {
if ([error isEqual:@{@"code": @401}]) {
[self refreshToken:^(NSDictionary *response) {
[self sendContext8:jsonData successBlock:^(NSDictionary *contextResponse) {
if (success) {
success(contextResponse);
}
} failureBlock:^(NSError *error) {
if (failure) {
failure(error);
}
}];
} failureBlock:^(NSError *error) {
if (failure) {
[_db executeUpdate:@"DROP TABLE requestVariables"];
failure(error);
}
NSLog(@"Error at token %@", error );
}];
}
NSLog(@"Error at get profile %@", error );
}];
}
......