This commit is contained in:
Igor Kislyuk 2018-03-26 20:21:37 +03:00
parent d53b4b84f6
commit 15ccb075b4
3 changed files with 23 additions and 7 deletions

View File

@ -77,7 +77,7 @@ open class BasePassCodeViewController: UIViewController, ConfigurableController
initialLoadView()
initialDotNumberConfiguration()
configureBackgroundNotifications()
showBiometricsRequestIfNeeded(with: biometricsAuthorizationHint)
showBiometricsRequestIfNeeded()
}
override open func viewWillAppear(_ animated: Bool) {
@ -149,12 +149,14 @@ open class BasePassCodeViewController: UIViewController, ConfigurableController
}
}
private func showBiometricsRequestIfNeeded(with description: String) {
private func showBiometricsRequestIfNeeded() {
guard viewModel.isBiometricsEnabled && viewModel.controllerType == .enter else {
return
}
viewModel.authenticateUsingBiometrics(with: description)
viewModel.authenticateUsingBiometrics(with: biometricsAuthorizationHint,
fallback: biometricsFallbackButtonTitle,
cancel: biometricsCancelButtonTitle)
}
private func resetUI() {
@ -166,10 +168,22 @@ open class BasePassCodeViewController: UIViewController, ConfigurableController
/// Returns prompt that appears on touch id system alert
open var biometricsAuthorizationHint: String {
assertionFailure("You should override this var: touchIdHint")
assertionFailure("You should override this \(#function)")
return ""
}
/// Returns prompt that appears on touch id system alert
open var biometricsFallbackButtonTitle: String? {
assertionFailure("You should override this \(#function)")
return nil
}
/// Returns prompt that appears on touch id system alert
open var biometricsCancelButtonTitle: String? {
assertionFailure("You should override this \(#function)")
return nil
}
/// Override to point certain images
open func imageFor(type: PinImageType) -> UIImage {
assertionFailure("You should override this method: imageFor(type: PinImageType)")

View File

@ -100,8 +100,8 @@ open class BasePassCodeViewModel: BaseViewModel {
passCodeHolder.reset()
}
public func authenticateUsingBiometrics(with description: String) {
biometricsService.authenticateWithBiometrics(with: description) { [weak self] success, error in
public func authenticateUsingBiometrics(with description: String, fallback: String?, cancel: String?) {
biometricsService.authenticateWithBiometrics(with: description, fallback: fallback, cancel: cancel) { [weak self] success, error in
if success {
self?.authSucceed(.touchId)
} else {

View File

@ -38,7 +38,9 @@ public final class BiometricsService {
Initiates system biometrics authentication process
- parameters:
- description: prompt on the system alert that describes what for user should attach finger to device
- description: prompt on the system alert
- fallback: alternative action button title on system alert
- cancel: cancel Button title on the system alert
- authHandler: callback, with parameter, indicates if user authenticate successfuly
*/
public func authenticateWithBiometrics(with description: String,