Skip to content

Commit 8f91e1d

Browse files
committed
Makes the reason in authenticateWithBiometrics injectable
See velikanov#21
1 parent b56bf7a commit 8f91e1d

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

PasscodeLock/PasscodeLock/PasscodeLock.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,14 @@ public class PasscodeLock: PasscodeLockType {
6868
guard isTouchIDAllowed else { return }
6969

7070
let context = LAContext()
71-
let reason = localizedStringFor("PasscodeLockTouchIDReason", comment: "TouchID authentication reason")
71+
72+
let reason: String
73+
if let configReason = configuration.touchIdReason {
74+
reason = configReason
75+
} else {
76+
reason = localizedStringFor("PasscodeLockTouchIDReason", comment: "TouchID authentication reason")
77+
}
78+
7279

7380
context.localizedFallbackTitle = localizedStringFor("PasscodeLockTouchIDButton", comment: "TouchID authentication fallback button")
7481

PasscodeLock/Protocols/PasscodeLockConfigurationType.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ public protocol PasscodeLockConfigurationType {
1414
var passcodeLength: Int {get}
1515
var isTouchIDAllowed: Bool {get set}
1616
var shouldRequestTouchIDImmediately: Bool {get}
17+
var touchIdReason: String? {get set}
1718
var maximumInccorectPasscodeAttempts: Int {get}
1819
}

PasscodeLockTests/Fakes/FakePasscodeLockConfiguration.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class FakePasscodeLockConfiguration: PasscodeLockConfigurationType {
1515
var isTouchIDAllowed = false
1616
let maximumInccorectPasscodeAttempts = 3
1717
let shouldRequestTouchIDImmediately = false
18+
var touchIdReason: String? = nil
1819

1920
init(repository: PasscodeRepositoryType) {
2021

0 commit comments

Comments
 (0)