From 381f0176fdf40a2c83e35424c252c55a35a5ec70 Mon Sep 17 00:00:00 2001 From: Ivan Grachyov Date: Sun, 13 Jun 2021 15:39:31 +0300 Subject: [PATCH] Ask for owner authentication only when applicable --- Encrypted Ink/Agent.swift | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Encrypted Ink/Agent.swift b/Encrypted Ink/Agent.swift index 6e519dc3..bb6bfa35 100644 --- a/Encrypted Ink/Agent.swift +++ b/Encrypted Ink/Agent.swift @@ -86,6 +86,13 @@ class Agent { private func proceedAfterAuthentication(reason: String, completion: @escaping (Bool) -> Void) { let context = LAContext() + + var error: NSError? + guard context.canEvaluatePolicy(.deviceOwnerAuthentication, error: &error) else { + completion(true) + return + } + context.localizedCancelTitle = "Cancel" context.evaluatePolicy(.deviceOwnerAuthentication, localizedReason: reason ) { success, _ in DispatchQueue.main.async {