Fix error conversion

This commit is contained in:
ismailgulek
2020-09-30 14:37:36 +03:00
parent bc633487f4
commit abac81fa87
2 changed files with 16 additions and 15 deletions

View File

@@ -99,10 +99,10 @@ extension KeychainStore: KeyValueStore {
}
func integer(forKey key: KeyValueStoreKey) throws -> Int? {
guard let stringValue = keychain.getString(key) else {
return nil
}
return try Int(stringValue)
guard let stringValue = try keychain.getString(key) else {
return nil
}
return Int(stringValue)
}
// remove

View File

@@ -104,19 +104,20 @@ final class SetupBiometricsViewModel: SetupBiometricsViewModelType {
LocalAuthenticationService.isShowingBiometrics = false
}
} else {
if let error = error as NSError? {
self.pinCodePreferences.numberOfBiometricsFailures += 1
if self.localAuthenticationService.shouldLogOutUser() {
// biometrics can't be used until further unlock with pin or a new log in
self.pinCodePreferences.canUseBiometricsToUnlock = false
DispatchQueue.main.async {
self.coordinatorDelegate?.setupBiometricsViewModelDidCompleteWithReset(self, dueToTooManyErrors: true)
LocalAuthenticationService.isShowingBiometrics = false
}
} else if error.code == LAError.Code.userCancel.rawValue || error.code == LAError.Code.userFallback.rawValue {
self.userCancelledUnlockWithBiometrics()
guard let error = error as NSError? else {
return
}
self.pinCodePreferences.numberOfBiometricsFailures += 1
if self.localAuthenticationService.shouldLogOutUser() {
// biometrics can't be used until further unlock with pin or a new log in
self.pinCodePreferences.canUseBiometricsToUnlock = false
DispatchQueue.main.async {
self.coordinatorDelegate?.setupBiometricsViewModelDidCompleteWithReset(self, dueToTooManyErrors: true)
LocalAuthenticationService.isShowingBiometrics = false
}
} else if error.code == LAError.Code.userCancel.rawValue || error.code == LAError.Code.userFallback.rawValue {
self.userCancelledUnlockWithBiometrics()
LocalAuthenticationService.isShowingBiometrics = false
}
}
}