Browse Source

improvements bruteforce

Signed-off-by: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com>
Marino Faggiana 1 year ago
parent
commit
7cd7dcae91
1 changed files with 9 additions and 6 deletions
  1. 9 6
      iOSClient/AppDelegate.swift

+ 9 - 6
iOSClient/AppDelegate.swift

@@ -789,11 +789,12 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
                     }
                 } else {
                     if let error = evaluateError {
-                        if error._code == LAError.authenticationFailed.rawValue {
+                        switch error._code {
+                        case LAError.userFallback.rawValue, LAError.authenticationFailed.rawValue:
                             NCKeychain().passcodeCounterFail = 3
-                            NCKeychain().passcodeCounterFailReset += 3
+                            NCKeychain().passcodeCounterFailReset += 1
                             self.openAlert(passcodeViewController: passcodeViewController)
-                        } else if error._code == LAError.biometryLockout.rawValue {
+                        case LAError.biometryLockout.rawValue:
                             LAContext().evaluatePolicy(LAPolicy.deviceOwnerAuthentication, localizedReason: NSLocalizedString("_deviceOwnerAuthentication_", comment: ""), reply: { success, _ in
                                 if success {
                                     DispatchQueue.main.async {
@@ -802,6 +803,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
                                     }
                                 }
                             })
+                        case LAError.userCancel.rawValue:
+                            NCKeychain().passcodeCounterFail += 1
+                            NCKeychain().passcodeCounterFailReset += 1
+                        default:
+                            break
                         }
                     }
                 }
@@ -837,9 +843,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
 
     func openAlert(passcodeViewController: TOPasscodeViewController) {
 
-        let passcodeCounterFail = NCKeychain().passcodeCounterFail
-        let passcodeCounterFailReset = NCKeychain().passcodeCounterFailReset
-
         DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
 
             if self.isPasscodeReset {