|
@@ -723,9 +723,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
|
|
|
|
|
|
func presentPasscode(completion: @escaping () -> Void) {
|
|
func presentPasscode(completion: @escaping () -> Void) {
|
|
|
|
|
|
- let laContext = LAContext()
|
|
|
|
var error: NSError?
|
|
var error: NSError?
|
|
-
|
|
|
|
defer { self.requestAccount() }
|
|
defer { self.requestAccount() }
|
|
|
|
|
|
let presentedViewController = window?.rootViewController?.presentedViewController
|
|
let presentedViewController = window?.rootViewController?.presentedViewController
|
|
@@ -737,13 +735,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
|
|
let passcodeViewController = TOPasscodeViewController(passcodeType: .sixDigits, allowCancel: false)
|
|
let passcodeViewController = TOPasscodeViewController(passcodeType: .sixDigits, allowCancel: false)
|
|
passcodeViewController.delegate = self
|
|
passcodeViewController.delegate = self
|
|
passcodeViewController.keypadButtonShowLettering = false
|
|
passcodeViewController.keypadButtonShowLettering = false
|
|
- if NCKeychain().touchFaceID,
|
|
|
|
- laContext.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &error),
|
|
|
|
- NCKeychain().passcodeCounterFail < 3 {
|
|
|
|
|
|
+ if NCKeychain().touchFaceID, LAContext().canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &error) {
|
|
if error == nil {
|
|
if error == nil {
|
|
- if laContext.biometryType == .faceID {
|
|
|
|
|
|
+ if LAContext().biometryType == .faceID {
|
|
passcodeViewController.biometryType = .faceID
|
|
passcodeViewController.biometryType = .faceID
|
|
- } else if laContext.biometryType == .touchID {
|
|
|
|
|
|
+ } else if LAContext().biometryType == .touchID {
|
|
passcodeViewController.biometryType = .touchID
|
|
passcodeViewController.biometryType = .touchID
|
|
}
|
|
}
|
|
passcodeViewController.allowBiometricValidation = true
|
|
passcodeViewController.allowBiometricValidation = true
|
|
@@ -753,9 +749,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
|
|
|
|
|
|
// show passcode on top of privacy window
|
|
// show passcode on top of privacy window
|
|
privacyProtectionWindow?.rootViewController?.present(passcodeViewController, animated: true, completion: {
|
|
privacyProtectionWindow?.rootViewController?.present(passcodeViewController, animated: true, completion: {
|
|
- let resetAppCounterFail = NCKeychain().resetAppCounterFail
|
|
|
|
let passcodeCounterFail = NCKeychain().passcodeCounterFail
|
|
let passcodeCounterFail = NCKeychain().passcodeCounterFail
|
|
- if resetAppCounterFail > 0 && (passcodeCounterFail >= resetAppCounterFail) {
|
|
|
|
|
|
+ if NCKeychain().resetAppCounterFail && (passcodeCounterFail >= NCBrandOptions.shared.resetAppPasscodeAttempts) {
|
|
self.passcodeResetApp(passcodeViewController)
|
|
self.passcodeResetApp(passcodeViewController)
|
|
} else if passcodeCounterFail >= 3 {
|
|
} else if passcodeCounterFail >= 3 {
|
|
self.passcodeAlert(passcodeViewController)
|
|
self.passcodeAlert(passcodeViewController)
|
|
@@ -773,12 +768,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
|
|
NCKeychain().touchFaceID,
|
|
NCKeychain().touchFaceID,
|
|
NCKeychain().passcode != nil,
|
|
NCKeychain().passcode != nil,
|
|
NCKeychain().requestPasscodeAtStart,
|
|
NCKeychain().requestPasscodeAtStart,
|
|
- NCKeychain().passcodeCounterFail < 3,
|
|
|
|
let passcodeViewController = privacyProtectionWindow?.rootViewController?.presentedViewController as? TOPasscodeViewController
|
|
let passcodeViewController = privacyProtectionWindow?.rootViewController?.presentedViewController as? TOPasscodeViewController
|
|
else { return }
|
|
else { return }
|
|
|
|
|
|
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
|
|
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
|
|
- LAContext().evaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, localizedReason: NCBrandOptions.shared.brand) { success, _ in
|
|
|
|
|
|
+ LAContext().evaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, localizedReason: NCBrandOptions.shared.brand) { success, evaluateError in
|
|
if success {
|
|
if success {
|
|
DispatchQueue.main.async {
|
|
DispatchQueue.main.async {
|
|
passcodeViewController.dismiss(animated: true) {
|
|
passcodeViewController.dismiss(animated: true) {
|
|
@@ -788,7 +782,17 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- NCKeychain().passcodeCounterFail += 1
|
|
|
|
|
|
+ if let error = evaluateError {
|
|
|
|
+ if error._code == LAError.authenticationFailed.rawValue {
|
|
|
|
+ // var error: NSError?
|
|
|
|
+ // LAContext().canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &error)
|
|
|
|
+ } else if error._code == LAError.biometryLockout.rawValue {
|
|
|
|
+ let reason = "TouchID has been locked out due to few fail attemp. Enter iPhone passcode to enable TouchID."
|
|
|
|
+ LAContext().evaluatePolicy(LAPolicy.deviceOwnerAuthentication, localizedReason: reason, reply: { success, _ in
|
|
|
|
+ if success { DispatchQueue.main.async { self.enableTouchFaceID() } }
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -809,9 +813,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
|
|
return true
|
|
return true
|
|
} else {
|
|
} else {
|
|
NCKeychain().passcodeCounterFail += 1
|
|
NCKeychain().passcodeCounterFail += 1
|
|
- let resetAppCounterFail = NCKeychain().resetAppCounterFail
|
|
|
|
let passcodeCounterFail = NCKeychain().passcodeCounterFail
|
|
let passcodeCounterFail = NCKeychain().passcodeCounterFail
|
|
- if resetAppCounterFail > 0 && (passcodeCounterFail >= resetAppCounterFail) {
|
|
|
|
|
|
+ if NCKeychain().resetAppCounterFail && (passcodeCounterFail >= NCBrandOptions.shared.resetAppPasscodeAttempts) {
|
|
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { self.passcodeResetApp(passcodeViewController) }
|
|
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { self.passcodeResetApp(passcodeViewController) }
|
|
} else if passcodeCounterFail >= 3 {
|
|
} else if passcodeCounterFail >= 3 {
|
|
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { self.passcodeAlert(passcodeViewController) }
|
|
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { self.passcodeAlert(passcodeViewController) }
|
|
@@ -833,7 +836,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
|
|
let alertController = UIAlertController(title: NSLocalizedString("_passcode_counter_fail_", comment: ""), message: nil, preferredStyle: .alert)
|
|
let alertController = UIAlertController(title: NSLocalizedString("_passcode_counter_fail_", comment: ""), message: nil, preferredStyle: .alert)
|
|
passcodeViewController.present(alertController, animated: true, completion: { })
|
|
passcodeViewController.present(alertController, animated: true, completion: { })
|
|
|
|
|
|
- var seconds = NCKeychain().passcodeSecondsFail * 30
|
|
|
|
|
|
+ var seconds = NCKeychain().passcodeSecondsFail * NCBrandOptions.shared.passcodeSecondsFail
|
|
_ = Timer.scheduledTimer(withTimeInterval: 1.0, repeats: true) { timer in
|
|
_ = Timer.scheduledTimer(withTimeInterval: 1.0, repeats: true) { timer in
|
|
alertController.message = "\(seconds) " + NSLocalizedString("_seconds_", comment: "")
|
|
alertController.message = "\(seconds) " + NSLocalizedString("_seconds_", comment: "")
|
|
seconds -= 1
|
|
seconds -= 1
|