marinofaggiana 4 years ago
parent
commit
0a17e26836

+ 5 - 3
iOSClient/AppDelegate.swift

@@ -195,11 +195,14 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         
         return true
     }
+    
+    // MARK: - Life Cycle
 
     // L' applicazione entrerà in primo piano (attivo sempre)
     func applicationDidBecomeActive(_ application: UIApplication) {
         
         NCSettingsBundleHelper.setVersionAndBuildNumber()
+        
         if account == "" { return}
 
         NCNetworking.shared.verifyUploadZombie()
@@ -520,7 +523,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         if account == "" { return }
         
         // check unauthorized server (401)
-        if CCUtility.getPasscode()?.count == 0 {
+        if CCUtility.getPassword(account)!.count == 0 {
             openLogin(viewController: window?.rootViewController, selector: NCGlobal.shared.introLogin, openLoginWeb: true)
         }
         
@@ -711,8 +714,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
                             guard let accountURL = URL(string: account.urlBase) else { return false }
                             if linkScheme.contains(accountURL.host ?? "") && userScheme == account.user {
                                 NCManageDatabase.shared.setAccountActive(account.account)
-                                guard let password = CCUtility.getPassword(account.account) else { return false }
-                                settingAccount(account.account, urlBase: account.urlBase, user: account.user, userId: account.userId, password: password)
+                                settingAccount(account.account, urlBase: account.urlBase, user: account.user, userId: account.userId, password: CCUtility.getPassword(account.account))
                                 matchedAccount = account
                                 NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterInitializeMain)
                             }

+ 4 - 2
iOSClient/Networking/NCNetworkingCheckRemoteUser.swift

@@ -45,7 +45,9 @@ import NCCommunication
         
         if serverVersionMajor >= NCGlobal.shared.nextcloudVersion17 {
             
-            guard let token = CCUtility.getPassword(account) else { return }
+            let token = CCUtility.getPassword(account)!
+            if token == "" { return }
+            //guard let token = CCUtility.getPassword(account) else { return }
             
             NCCommunication.shared.getRemoteWipeStatus(serverUrl: tableAccount.urlBase, token: token) { (account, wipe, errorCode, errorDescriptiuon) in
                 
@@ -69,7 +71,7 @@ import NCCommunication
                 self.checkRemoteUserInProgress = false
             }
             
-        } else if CCUtility.getPassword(account) != nil {
+        } else if CCUtility.getPassword(account) != "" {
                
             if UIApplication.shared.applicationState == .active &&  NCCommunication.shared.isNetworkReachable() {
                 let description = String.localizedStringWithFormat(NSLocalizedString("_error_check_remote_user_", comment: ""), tableAccount.user, tableAccount.urlBase)

+ 3 - 1
iOSClient/Utility/CCUtility.m

@@ -502,7 +502,9 @@
 + (NSString *)getPassword:(NSString *)account
 {
     NSString *key = [@"password" stringByAppendingString:account];
-    return [UICKeyChainStore stringForKey:key service:NCGlobal.shared.serviceShareKeyChain];
+    NSString *result = [UICKeyChainStore stringForKey:key service:NCGlobal.shared.serviceShareKeyChain];
+    if (result == nil) { result = @""; }
+    return result;
 }
 
 + (void)setHCBusinessType:(NSString *)professions