From c880762e85294b0a38cfa37109a45cefee733d25 Mon Sep 17 00:00:00 2001 From: nasli Date: Wed, 22 Nov 2017 13:16:12 +0100 Subject: [PATCH] Fix bug use wrong cookies after enter an user that already exist --- Owncloud iOs Client/AppDelegate.m | 8 ++++---- .../Login/Login/UniversalLoginViewController.swift | 6 ++++++ Owncloud iOs Client/Network/UserData/DetectUserData.m | 10 +++------- ownCloudExtApp/DocumentPickerViewController.m | 4 ++-- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/Owncloud iOs Client/AppDelegate.m b/Owncloud iOs Client/AppDelegate.m index d53b255122..0e7576f650 100644 --- a/Owncloud iOs Client/AppDelegate.m +++ b/Owncloud iOs Client/AppDelegate.m @@ -595,9 +595,9 @@ + (OCCommunication*)sharedOCCommunication authorizationEndpoint:k_oauth2_authorization_endpoint tokenEndpoint:k_oauth2_token_endpoint]; - [sharedOCCommunication setOauth2Configuration: ocOAuth2conf]; + [sharedOCCommunication setValueOauth2Configuration: ocOAuth2conf]; - [sharedOCCommunication setUserAgent:[UtilsUrls getUserAgent]]; + [sharedOCCommunication setValueOfUserAgent:[UtilsUrls getUserAgent]]; OCKeychain *oKeychain = [[OCKeychain alloc] init]; [sharedOCCommunication setValueCredentialsStorage:oKeychain]; @@ -639,9 +639,9 @@ + (OCCommunication*)sharedOCCommunicationDownloadFolder { authorizationEndpoint:k_oauth2_authorization_endpoint tokenEndpoint:k_oauth2_token_endpoint]; - [sharedOCCommunicationDownloadFolder setOauth2Configuration:ocOAuth2conf]; + [sharedOCCommunicationDownloadFolder setValueOauth2Configuration:ocOAuth2conf]; - [sharedOCCommunicationDownloadFolder setUserAgent:[UtilsUrls getUserAgent]]; + [sharedOCCommunicationDownloadFolder setValueOfUserAgent:[UtilsUrls getUserAgent]]; OCKeychain *oKeychain = [[OCKeychain alloc] init]; [sharedOCCommunicationDownloadFolder setValueCredentialsStorage:oKeychain]; diff --git a/Owncloud iOs Client/Login/Login/UniversalLoginViewController.swift b/Owncloud iOs Client/Login/Login/UniversalLoginViewController.swift index e41b0cb265..852f162073 100644 --- a/Owncloud iOs Client/Login/Login/UniversalLoginViewController.swift +++ b/Owncloud iOs Client/Login/Login/UniversalLoginViewController.swift @@ -869,6 +869,9 @@ public enum TextfieldType: String { if tryingToUpdateDifferentUser { self.showCredentialsError(NSLocalizedString("credentials_different_user", comment: "") ) + //Delete current wrong cookies and relaunch check url to get correct ones + UtilsFramework.deleteAllCookies() + self.checkCurrentUrl() } else { @@ -885,6 +888,9 @@ public enum TextfieldType: String { if (ManageUsersDB.isExistUser(self.user)) { self.showURLError(NSLocalizedString("account_not_new", comment: "")) + //Delete current wrong cookies and relaunch check url to get correct ones + UtilsFramework.deleteAllCookies() + self.checkCurrentUrl() } else { diff --git a/Owncloud iOs Client/Network/UserData/DetectUserData.m b/Owncloud iOs Client/Network/UserData/DetectUserData.m index df87747110..e2d7a7da20 100644 --- a/Owncloud iOs Client/Network/UserData/DetectUserData.m +++ b/Owncloud iOs Client/Network/UserData/DetectUserData.m @@ -26,16 +26,12 @@ @implementation DetectUserData + (void) getUserDisplayNameOfServer:(NSString*)path credentials:(OCCredentialsDto *)credentials withCompletion:(void(^)(NSString *displayName, NSError *error))completion { - OCCommunication *sharedCommunication; - sharedCommunication = [AppDelegate sharedOCCommunication]; - - - [sharedCommunication setCredentials:credentials]; + [[AppDelegate sharedOCCommunication] setCredentials:credentials]; - [sharedCommunication setValueOfUserAgent:[UtilsUrls getUserAgent]]; + [[AppDelegate sharedOCCommunication] setValueOfUserAgent:[UtilsUrls getUserAgent]]; - [sharedCommunication getUserDisplayNameOfServer:path onCommunication:sharedCommunication + [[AppDelegate sharedOCCommunication] getUserDisplayNameOfServer:path onCommunication:[AppDelegate sharedOCCommunication] success:^(NSHTTPURLResponse *response, NSString *displayName, NSString *redirectedServer) { if (displayName && ![displayName isEqualToString:@""]) { completion(displayName, nil); diff --git a/ownCloudExtApp/DocumentPickerViewController.m b/ownCloudExtApp/DocumentPickerViewController.m index b141d40a6e..d379027bfe 100644 --- a/ownCloudExtApp/DocumentPickerViewController.m +++ b/ownCloudExtApp/DocumentPickerViewController.m @@ -171,9 +171,9 @@ + (OCCommunication*)sharedOCCommunication authorizationEndpoint:k_oauth2_authorization_endpoint tokenEndpoint:k_oauth2_token_endpoint]; - [sharedOCCommunication setOauth2Configuration: ocOAuth2conf]; + [sharedOCCommunication setValueOauth2Configuration: ocOAuth2conf]; - [sharedOCCommunication setUserAgent:[UtilsUrls getUserAgent]]; + [sharedOCCommunication setValueOfUserAgent:[UtilsUrls getUserAgent]]; OCKeychain *oKeychain = [[OCKeychain alloc] init]; [sharedOCCommunication setValueCredentialsStorage:oKeychain];