Rename to biometrics

This commit is contained in:
Igor Kislyuk 2018-03-23 15:52:34 +03:00
parent 7b6e73e789
commit 27f42e55a1
3 changed files with 26 additions and 24 deletions

View File

@ -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
}

View File

@ -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()

View File

@ -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
}
}