Skip to content

Commit daa0088

Browse files
PM-10519: Fix Face ID toggled off if device is locked while performing Face ID (#783)
1 parent ce87e4e commit daa0088

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

BitwardenShared/Core/Auth/Services/Biometrics/BiometricsRepository.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ class DefaultBiometricsRepository: BiometricsRepository {
152152
switch status {
153153
case kLAErrorBiometryLockout:
154154
throw BiometricsServiceError.biometryLocked
155-
case errSecUserCanceled,
155+
case errSecAuthFailed,
156+
errSecUserCanceled,
156157
kLAErrorAppCancel,
157158
kLAErrorSystemCancel,
158159
kLAErrorUserCancel:

BitwardenShared/Core/Auth/Services/Biometrics/BiometricsRepositoryTests.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,18 @@ final class BiometricsRepositoryTests: BitwardenTestCase { // swiftlint:disable:
111111
XCTAssertEqual(key, expectedKey)
112112
}
113113

114+
/// `setBiometricUnlockKey` throws a cancelled error for `errSecAuthFailed` if the device is
115+
/// locked while performing biometrics.
116+
func test_getBiometricUnlockKey_authFailed() async throws {
117+
stateService.activeAccount = .fixture()
118+
keychainService.getResult = .failure(
119+
KeychainServiceError.osStatusError(errSecAuthFailed)
120+
)
121+
await assertAsyncThrows(error: BiometricsServiceError.biometryCancelled) {
122+
_ = try await subject.getUserAuthKey()
123+
}
124+
}
125+
114126
/// `getBiometricUnlockStatus` throws an error if the user has locked biometrics.
115127
func test_getBiometricUnlockStatus_lockout() async throws {
116128
let active = Account.fixture()

0 commit comments

Comments
 (0)