Browse Source

fix clear token

Signed-off-by: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com>
Marino Faggiana 1 year ago
parent
commit
57e86bb4f6

+ 4 - 10
iOSClient/AppDelegate.swift

@@ -862,13 +862,13 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         passcodeViewController.present(alertController, animated: true, completion: { })
 
         DispatchQueue.main.asyncAfter(deadline: .now() + 4) {
-            self.removeAllSettings(killEmAll: true)
+            self.resetApplication()
         }
     }
 
-    // MARK: - Remove All Settings
+    // MARK: - Reset Application
 
-    @objc func removeAllSettings(killEmAll: Bool) {
+    @objc func resetApplication() {
 
         let utilityFileSystem = NCUtilityFileSystem()
 
@@ -886,13 +886,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         utilityFileSystem.removeTemporaryDirectory()
 
         NCKeychain().removeAll()
-
-        if killEmAll {
-            NCManageDatabase.shared.removeDB()
-            exit(0)
-        } else {
-            NCManageDatabase.shared.clearDatabase(account: nil, removeAccount: true)
-        }
+        exit(0)
     }
 
     // MARK: - Privacy Protection

+ 0 - 4
iOSClient/Login/NCLogin.swift

@@ -395,10 +395,6 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
 
                 if error == .success, let userProfile {
 
-                    if NCManageDatabase.shared.getAccounts() == nil {
-                        self.appDelegate.removeAllSettings(killEmAll: false)
-                    }
-
                     NCManageDatabase.shared.deleteAccount(account)
                     NCManageDatabase.shared.addAccount(account, urlBase: url, user: user, userId: userProfile.userId, password: password)
 

+ 0 - 4
iOSClient/Login/NCLoginWeb.swift

@@ -293,10 +293,6 @@ extension NCLoginWeb: WKNavigationDelegate {
 
             if error == .success, let userProfile {
 
-                if NCManageDatabase.shared.getAccounts() == nil {
-                    self.appDelegate.removeAllSettings(killEmAll: false)
-                }
-
                 NCManageDatabase.shared.deleteAccount(account)
                 NCManageDatabase.shared.addAccount(account, urlBase: urlBase, user: user, userId: userProfile.userId, password: password)
 

+ 1 - 1
iOSClient/Settings/CCAdvanced.m

@@ -455,7 +455,7 @@
     UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"" message:NSLocalizedString(@"_want_exit_", nil) preferredStyle:UIAlertControllerStyleActionSheet];
     
     [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
-        [appDelegate removeAllSettingsWithKillEmAll:true];
+        [appDelegate resetApplication];
     }]];
     
     [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_cancel_", nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {

+ 12 - 0
iOSClient/Settings/NCKeychain.swift

@@ -78,6 +78,18 @@ import KeychainAccess
         }
     }
 
+    var biometricsCounterFail: Int {
+        get {
+            if let value = try? keychain.get("biometricsCounterFail"), let result = Int(value) {
+                return result
+            }
+            return 0
+        }
+        set {
+            keychain["biometricsCounterFail"] = String(newValue)
+        }
+    }
+
     @objc var requestPasscodeAtStart: Bool {
         get {
             let keychainOLD = Keychain(service: "Crypto Cloud")

+ 1 - 1
iOSClient/Settings/NCSettingsBundleHelper.swift

@@ -41,7 +41,7 @@ class NCSettingsBundleHelper: NSObject {
 
             DispatchQueue.main.asyncAfter(deadline: .now() + delay) {
                 let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
-                appDelegate.removeAllSettings(killEmAll: true)
+                appDelegate.resetApplication()
             }
         }
     }