Skip to content

Commit f8f6e36

Browse files
Always reset the LAContext if we're trying to force a biometric prompt (#595)
1 parent 6d811a0 commit f8f6e36

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Sources/StytchCore/StytchClient/Biometrics/StytchClient+Biometrics.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ public extension StytchClient {
115115
}
116116

117117
if parameters.shouldEvaluatePolicyOnRegister == true {
118+
LocalAuthenticationContextManager.laContext = LAContext()
119+
LocalAuthenticationContextManager.updateLaContextStrings(strings: parameters.promptStrings)
118120
guard try await LocalAuthenticationContextManager.localAuthenticationContext.evaluatePolicy(parameters.accessPolicy, localizedReason: parameters.promptStrings.localizedReason) else {
119121
throw StytchSDKError.biometricAuthenticationFailed
120122
}
@@ -164,10 +166,11 @@ public extension StytchClient {
164166
guard let privateKeyRegistrationQueryResult: KeychainQueryResult = try keychainClient.getQueryResults(item: .privateKeyRegistration).first else {
165167
throw StytchSDKError.noBiometricRegistration
166168
}
169+
LocalAuthenticationContextManager.laContext = LAContext()
170+
LocalAuthenticationContextManager.updateLaContextStrings(strings: parameters.promptStrings)
167171
guard try await LocalAuthenticationContextManager.localAuthenticationContext.evaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, localizedReason: parameters.promptStrings.localizedReason) else {
168172
throw StytchSDKError.biometricAuthenticationFailed
169173
}
170-
LocalAuthenticationContextManager.updateLaContextStrings(strings: parameters.promptStrings)
171174

172175
try copyBiometricRegistrationIDToKeychainIfNeeded(privateKeyRegistrationQueryResult)
173176

0 commit comments

Comments
 (0)