Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a bug where pin auth events would not get sent correctly #67

Merged
merged 1 commit into from
Mar 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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