Commit 338ab7eb authored by Soomin Lee's avatar Soomin Lee Committed by Carola Nitz

KeychainCoordinator: Fix touchID and faceID not ever showing after a successful unlock

The LAContext needs to be reinstanciated every time otherwise it will
cache a successful unlock.
Signed-off-by: default avatarCarola Nitz <nitz.carola@googlemail.com>
parent 3ec6f825
......@@ -19,13 +19,14 @@ class KeychainCoordinator:NSObject, PAPasscodeViewControllerDelegate {
@objc class var passcodeLockEnabled:Bool {
return UserDefaults.standard.bool(forKey:kVLCSettingPasscodeOnKey)
}
private var laContext = LAContext()
//Since FaceID and TouchID are both set to 1 when the defaults are registered
//we have to double check for the biometry type to not return true even though the setting is not visible
//and that type is not supported by the device
private var touchIDEnabled:Bool {
var touchIDEnabled = UserDefaults.standard.bool(forKey:kVLCSettingPasscodeAllowTouchID)
let laContext = LAContext()
if #available(iOS 11.0, *), laContext.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: nil) {
touchIDEnabled = touchIDEnabled && laContext.biometryType == .touchID
}
......@@ -33,6 +34,8 @@ class KeychainCoordinator:NSObject, PAPasscodeViewControllerDelegate {
}
private var faceIDEnabled:Bool {
var faceIDEnabled = UserDefaults.standard.bool(forKey:kVLCSettingPasscodeAllowFaceID)
let laContext = LAContext()
if #available(iOS 11.0, *), laContext.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: nil) {
faceIDEnabled = faceIDEnabled && laContext.biometryType == .faceID
}
......@@ -110,6 +113,8 @@ class KeychainCoordinator:NSObject, PAPasscodeViewControllerDelegate {
return
}
let laContext = LAContext()
if laContext.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: nil){
avoidPromptingTouchOrFaceID = true
laContext.evaluatePolicy(.deviceOwnerAuthenticationWithBiometrics,
......@@ -127,7 +132,6 @@ class KeychainCoordinator:NSObject, PAPasscodeViewControllerDelegate {
self?.avoidPromptingTouchOrFaceID = true
}
}
})
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment