From 27f42e55a1dbb10f8fdaa475b31d29cc3a913e47 Mon Sep 17 00:00:00 2001 From: Igor Kislyuk Date: Fri, 23 Mar 2018 15:52:34 +0300 Subject: [PATCH] Rename to biometrics --- .../View/BasePassCodeViewController.swift | 6 ++-- .../ViewModel/BasePassCodeViewModel.swift | 14 ++++----- .../Services/BasePassCodeService.swift | 30 ++++++++++--------- 3 files changed, 26 insertions(+), 24 deletions(-) diff --git a/LeadKitAdditions/Sources/Controllers/PassCode/View/BasePassCodeViewController.swift b/LeadKitAdditions/Sources/Controllers/PassCode/View/BasePassCodeViewController.swift index 5d45e8c..b246456 100644 --- a/LeadKitAdditions/Sources/Controllers/PassCode/View/BasePassCodeViewController.swift +++ b/LeadKitAdditions/Sources/Controllers/PassCode/View/BasePassCodeViewController.swift @@ -77,7 +77,7 @@ open class BasePassCodeViewController: UIViewController, ConfigurableController initialLoadView() initialDotNumberConfiguration() configureBackgroundNotifications() - showTouchIdIfNeeded(with: touchIdHint) + showBiometricsRequestIfNeeded(with: touchIdHint) } override open func viewWillAppear(_ animated: Bool) { @@ -149,8 +149,8 @@ open class BasePassCodeViewController: UIViewController, ConfigurableController } } - private func showTouchIdIfNeeded(with description: String) { - guard viewModel.isTouchIdEnabled && viewModel.controllerType == .enter else { + private func showBiometricsRequestIfNeeded(with description: String) { + guard viewModel.isBiometricsEnabled && viewModel.controllerType == .enter else { return } diff --git a/LeadKitAdditions/Sources/Controllers/PassCode/ViewModel/BasePassCodeViewModel.swift b/LeadKitAdditions/Sources/Controllers/PassCode/ViewModel/BasePassCodeViewModel.swift index 2e4245a..505c715 100644 --- a/LeadKitAdditions/Sources/Controllers/PassCode/ViewModel/BasePassCodeViewModel.swift +++ b/LeadKitAdditions/Sources/Controllers/PassCode/ViewModel/BasePassCodeViewModel.swift @@ -138,23 +138,23 @@ open class BasePassCodeViewModel: BaseViewModel { assertionFailure("You should override this method: authSucceed(_ type: PassCodeAuthType)") } - // MARK: - Functions that can you can override to use TouchId + // MARK: - Biometrics - /// Override to be able use touchId during authentication - open var isTouchIdEnabled: Bool { + /// Posibility to use biometrics for authentication + open var isBiometricsEnabled: Bool { return false } - /// You should save user choice about authenticate by touchId - open func activateTouchIdForUser() { - assertionFailure("You should override this method: activateTouchIdForUser()") + /// Notify about activation for biometrics. Remember to save user choice + open func activateBiometricsForUser() { + assertionFailure("You should override this method: activateBiometricsForUser()") } } extension BasePassCodeViewModel { - fileprivate func set(passCode: String) { + private func set(passCode: String) { passCodeHolder.add(passCode: passCode) validateIfNeeded() diff --git a/LeadKitAdditions/Sources/Services/BasePassCodeService.swift b/LeadKitAdditions/Sources/Services/BasePassCodeService.swift index a7a9c67..b79d6ea 100644 --- a/LeadKitAdditions/Sources/Services/BasePassCodeService.swift +++ b/LeadKitAdditions/Sources/Services/BasePassCodeService.swift @@ -24,6 +24,17 @@ import KeychainAccess import CocoaLumberjack import IDZSwiftCommonCrypto +private enum Keys { + static let passCodeHash = "passCodeHashKey" + static let isBiometricsEnabled = "isBiometricsEnabledKey" + static let isInitialLoad = "isInitialLoadKey" +} + +private enum Values { + static let biometricsEnabled = "biometricsEnabled" + static let initialLoad = "initialLoad" +} + /// Represents base pass code service which encapsulates pass code storing open class BasePassCodeService { @@ -48,16 +59,7 @@ open class BasePassCodeService { return keychain[Keys.passCodeHash] } - private enum Keys { - static let passCodeHash = "passCodeHash" - static let isTouchIdEnabled = "isTouchIdEnabled" - static let isInitialLoad = "isInitialLoad" - } - private enum Values { - static let touchIdEnabled = "touchIdEnabled" - static let initialLoad = "initialLoad" - } } @@ -68,13 +70,13 @@ public extension BasePassCodeService { return keychain[Keys.passCodeHash] != nil } - /// Indicates is it possible to authenticate on this device via touch id - var isTouchIdEnabled: Bool { + /// Possibility to authenticate via biometrics. TouchID or FaceID + var isBiometricsAuthorizationEnabled: Bool { get { - return keychain[Keys.isTouchIdEnabled] == Values.touchIdEnabled + return keychain[Keys.isBiometricsEnabled] == Values.biometricsEnabled } set { - keychain[Keys.isTouchIdEnabled] = newValue ? Values.touchIdEnabled : nil + keychain[Keys.isBiometricsEnabled] = newValue ? Values.biometricsEnabled : nil } } @@ -95,7 +97,7 @@ public extension BasePassCodeService { /// Reset pass code settings func reset() { save(passCode: nil) - isTouchIdEnabled = false + isBiometricsAuthorizationEnabled = false } }