Fixed setting LAContext (may only be set when saving item)

This commit is contained in:
dankito 2020-10-02 04:44:25 +02:00
parent ab5506f7eb
commit 97b78bd8c4
2 changed files with 8 additions and 8 deletions

View File

@ -160,9 +160,8 @@ class AuthenticationService {
.userPresence,
nil) // Ignore any error.
// TODO: this does not work yet, setting LAContext results in a "unexpectedPasswordData" error
// context = LAContext()
// context?.touchIDAuthenticationAllowableReuseDuration = 45
context = LAContext()
context?.touchIDAuthenticationAllowableReuseDuration = 45
}
return KeychainPasswordItem(service: Self.DefaultPasswordKeychainAccountName, account: nil, accessGroup: nil, secAccessControl: accessControl, authenticationContext: context)

View File

@ -135,7 +135,12 @@ struct KeychainPasswordItem {
var attributesToUpdate = [String : AnyObject]()
attributesToUpdate[kSecValueData as String] = encodedPassword as AnyObject?
let query = keychainQuery()
var query = keychainQuery()
if let authenticationContext = authenticationContext {
query[kSecUseAuthenticationContext as String] = authenticationContext
}
let status = SecItemUpdate(query as CFDictionary, attributesToUpdate as CFDictionary)
// Throw an error if an unexpected status was returned.
@ -198,10 +203,6 @@ struct KeychainPasswordItem {
query[kSecAttrAccessControl as String] = accessControl as AnyObject?
}
if let authenticationContext = authenticationContext {
query[kSecUseAuthenticationContext as String] = authenticationContext
}
return query
}