Skip to content

Commit

Permalink
update protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
mayckonx committed Mar 8, 2019
1 parent f3b58ca commit 16c7603
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions MBSPasswordView/Classes/Protocols/MBSAuthenticatable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ public enum MBSAuthenticationIDError: Error {
public protocol MBSAuthenticatable {
func isTouchIDAvailable() -> Bool
func isFaceIDAvailable() -> Bool
func authenticateByBiometrics(title: String, result: @escaping ((Result<Bool>) -> Void))
func authenticateByBiometrics(title: String, result: @escaping ((MBSPasswordResult<Bool>) -> Void))
}

extension MBSAuthenticatable where Self: UIView {
public func authenticateByBiometrics(title: String, result: @escaping ((Result<Bool>) -> Void)) {
public func authenticateByBiometrics(title: String, result: @escaping ((MBSPasswordResult<Bool>) -> Void)) {
let context = LAContext()
var error: NSError?

Expand Down
6 changes: 3 additions & 3 deletions MBSPasswordView/Classes/UI/MBSPasswordView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public protocol MBSPasswordViewType {

public protocol MBSPasswordDelegate: class {
func password(_ result: [String])
func passwordFromBiometrics(_ result: Result<[String]>)
func passwordFromBiometrics(_ result: MBSPasswordResult<[String]>)
}

public class MBSPasswordView: UIView, MBSPasswordViewType {
Expand Down Expand Up @@ -137,11 +137,11 @@ extension MBSPasswordView: MBSAuthenticatable {
self.authenticateByBiometrics(title: titleToRequestAuthentication) { result in
switch result {
case .success:
self.delegate?.passwordFromBiometrics(Result.success(password))
self.delegate?.passwordFromBiometrics(MBSPasswordResult.success(password))
case .error(let error):
// we won't request on the next try... User should try by password
self.enableBiometricsAuthentication = false
self.delegate?.passwordFromBiometrics(Result.error(error))
self.delegate?.passwordFromBiometrics(MBSPasswordResult.error(error))
}
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion MBSPasswordView/Classes/ext/UIViewController+ext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ import Foundation
// Workaround to make those method optionals
// Perhaps the user wants to use only one of them
extension MBSPasswordDelegate where Self: UIViewController {
func passwordFromBiometrics(_ result: Result<[String]>) {}
func passwordFromBiometrics(_ result: MBSPasswordResult<[String]>) {}
func password(_ result: [String]) {}
}

0 comments on commit 16c7603

Please sign in to comment.