Skip to content

Commit

Permalink
Merge pull request #67 from onewelcome/hotfix/ios_pin_auth
Browse files Browse the repository at this point in the history
Fix a bug where pin auth events would not get sent correctly
  • Loading branch information
MichielVrins authored Mar 23, 2023
2 parents b0f18ae + 881e65d commit 5bdd6f0
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions ios/Classes/NativeBridge/Handlers/LoginHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,25 @@ class LoginHandler: NSObject {
completion(.success)
}

private func mapErrorFromPinChallenge(_ challenge: ONGPinChallenge) -> Error? {
if let error = challenge.error, error.code != ONGAuthenticationError.touchIDAuthenticatorFailure.rawValue {
return error
} else {
return nil
}
}

func handleDidReceiveChallenge(_ challenge: ONGPinChallenge) {
pinChallenge = challenge
guard challenge.error?.code != ONGAuthenticationError.touchIDAuthenticatorFailure.rawValue else {
SwiftOneginiPlugin.flutterApi?.n2fOpenPinScreenAuth {}
guard mapErrorFromPinChallenge(challenge) == nil else {
let authAttempt = OWAuthenticationAttempt(
failedAttempts: Int64(challenge.previousFailureCount),
maxAttempts: Int64(challenge.maxFailureCount),
remainingAttempts: Int64(challenge.remainingFailureCount))
SwiftOneginiPlugin.flutterApi?.n2fNextAuthenticationAttempt(authenticationAttempt: authAttempt) {}
return
}
let authAttempt = OWAuthenticationAttempt(
failedAttempts: Int64(challenge.previousFailureCount),
maxAttempts: Int64(challenge.maxFailureCount),
remainingAttempts: Int64(challenge.remainingFailureCount))
SwiftOneginiPlugin.flutterApi?.n2fNextAuthenticationAttempt(authenticationAttempt: authAttempt) {}
SwiftOneginiPlugin.flutterApi?.n2fOpenPinScreenAuth {}
}

func handleDidAuthenticateUser() {
Expand Down

0 comments on commit 5bdd6f0

Please sign in to comment.