Merge branch 'develop' into 'master'

- Fix



See merge request !12
This commit is contained in:
Giuseppe Nucifora 2016-02-05 08:39:12 +00:00
commit 2e9dc91fc6
2 changed files with 37 additions and 47 deletions

View File

@ -19,22 +19,12 @@
// Override point for customization after application launch. // Override point for customization after application launch.
[PNObjectConfig initSharedInstanceForEnvironments:@{EnvironmentDevelopment : @"http://packman.local/app_dev.php/api/v1/",
EnvironmentStage : @"http://packman.ppreview.it/app_stage.php/api/v1/",
EnvironmentProduction : @"http://packman.ppreview.it/app_stage.php/api/v1/"
} withOauth:YES];
[[PNObjectConfig sharedInstance] setHTTPHeaderValue:@"application/x-www-form-urlencoded" forKey:@"Content-Type"];
[[PNObjectConfig sharedInstance] setClientID:@"1_pqjo2w5k7j4g8skco408oc048w8so0ws840gcg8k8gwsgk0g4" clientSecret:@"10w0vg2v6eggooc4wks4w4s0wkwok0wkck0w888so0o80g88w8" forEnv:Stage];
#ifdef DEBUG
[[PNObjectConfig sharedInstance] setEnvironment:Stage];
#endif [PNObjectConfig initSharedInstanceForEnvironments:@{ EnvironmentDevelopment : @"https://development.it/api/v1",
/*[PNObjectConfig initSharedInstanceForEnvironments:@{ EnvironmentDevelopment : @"https://development.it/api/v1",
EnvironmentStage : @"https://stage.it/api/v1", EnvironmentStage : @"https://stage.it/api/v1",
EnvironmentProduction : @"https://pnobject.giuseppenucifora.com/" EnvironmentProduction : @"https://pnobject.giuseppenucifora.com/"
}]; } withOauth:NO];
[[PNObjectConfig sharedInstance] setEnvironment:Production]; [[PNObjectConfig sharedInstance] setEnvironment:Production];
@ -65,7 +55,7 @@
[user setFirstName:@"Angela"]; [user setFirstName:@"Angela"];
[user setLastName:@"Sapienza"]; [user setLastName:@"Sapienza"];
[user getJSONObject];*/ [user JSONObject];
/*[[[PNObjectConfig sharedInstance] manager] GET:[[[PNObjectConfig sharedInstance] baseUrl] stringByAppendingString:[PNAccessToken PNObjEndPoint]] parameters:nil progress:^(NSProgress * _Nonnull downloadProgress) { /*[[[PNObjectConfig sharedInstance] manager] GET:[[[PNObjectConfig sharedInstance] baseUrl] stringByAppendingString:[PNAccessToken PNObjEndPoint]] parameters:nil progress:^(NSProgress * _Nonnull downloadProgress) {

View File

@ -224,8 +224,8 @@ static bool isFirstAccess = YES;
} }
- (void) tryRefreshToken { - (void) tryRefreshToken {
if (![PNUser currentUser]) { if ([PNUser currentUser]) {
[_manager authenticateUsingOAuthWithURLString:[_currentEndPointBaseUrl stringByAppendingString:@"oauth-token"] username:[[PNUser currentUser] username] password:[[PNUser currentUser] password] scope:kAFOAuthPasswordCredentialsGrantType success:^(AFOAuthCredential * _Nonnull credential) { [_manager authenticateUsingOAuthWithURLString:[_currentEndPointBaseUrl stringByAppendingString:@"oauth-token"] username:[[PNUser currentUser] username] password:[[PNUser currentUser] password] scope:nil success:^(AFOAuthCredential * _Nonnull credential) {
_currentOauthCredential = credential; _currentOauthCredential = credential;
[_manager.requestSerializer setAuthorizationHeaderFieldWithCredential:_currentOauthCredential]; [_manager.requestSerializer setAuthorizationHeaderFieldWithCredential:_currentOauthCredential];
} failure:^(NSError * _Nonnull error) { } failure:^(NSError * _Nonnull error) {
@ -234,7 +234,7 @@ static bool isFirstAccess = YES;
} }
else { else {
[_manager authenticateUsingOAuthWithURLString:[_currentEndPointBaseUrl stringByAppendingString:@"oauth-token"] scope:kAFOAuthClientCredentialsGrantType success:^(AFOAuthCredential * _Nonnull credential) { [_manager authenticateUsingOAuthWithURLString:[_currentEndPointBaseUrl stringByAppendingString:@"oauth-token"] scope:nil success:^(AFOAuthCredential * _Nonnull credential) {
_currentOauthCredential = credential; _currentOauthCredential = credential;
[_manager.requestSerializer setAuthorizationHeaderFieldWithCredential:_currentOauthCredential]; [_manager.requestSerializer setAuthorizationHeaderFieldWithCredential:_currentOauthCredential];
} failure:^(NSError * _Nonnull error) { } failure:^(NSError * _Nonnull error) {