Skip to content

Commit

Permalink
fix user cancel error handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
hpoul committed Sep 8, 2019
1 parent 3cd4d0b commit c6df4cb
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions macos/Classes/BiometricStorageImpl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class BiometricStorageImpl {
return
}
guard status == errSecSuccess else {
result(storageError(code: "RetrieveError", message: "Error retrieving item. \(status)", details: nil))
handleOSStatusError(status, result, "Error retrieving item. \(status)")
return
}
guard let existingItem = item as? [String : Any],
Expand Down Expand Up @@ -183,8 +183,15 @@ class BiometricStorageImpl {
if #available(iOS 11.3, OSX 10.12, *) {
errorMessage = SecCopyErrorMessageString(status, nil) as String?
}
let code: String
switch status {
case errSecUserCanceled:
code = "AuthError:UserCanceled"
default:
code = "SecurityError"
}

result(storageError(code: "SecurityError", message: "Error while \(message): \(status): \(errorMessage ?? "Unknown")", details: nil))
result(storageError(code: code, message: "Error while \(message): \(status): \(errorMessage ?? "Unknown")", details: nil))
}

private func canAuthenticate(result: @escaping StorageCallback) {
Expand Down

0 comments on commit c6df4cb

Please sign in to comment.