Add AppLockSetupPINScreen. (#1930)

This commit is contained in:
Doug
2023-10-23 10:07:13 +01:00
committed by GitHub
parent ceee6b1853
commit 5356a56a00
27 changed files with 811 additions and 7 deletions
@@ -47,8 +47,8 @@ class AppLockService: AppLockServiceProtocol {
}
func setupPINCode(_ pinCode: String) -> Result<Void, AppLockServiceError> {
guard validate(pinCode) else { return .failure(.invalidPIN) }
guard !appSettings.appLockPINCodeBlockList.contains(pinCode) else { return .failure(.weakPIN) }
let result = validate(pinCode)
guard case .success = result else { return result }
do {
try keychainController.setPINCode(pinCode)
@@ -59,6 +59,12 @@ class AppLockService: AppLockServiceProtocol {
}
}
func validate(_ pinCode: String) -> Result<Void, AppLockServiceError> {
guard pinCode.count == 4, pinCode.allSatisfy(\.isNumber) else { return .failure(.invalidPIN) }
guard !appSettings.appLockPINCodeBlockList.contains(pinCode) else { return .failure(.weakPIN) }
return .success(())
}
func disable() {
biometricUnlockEnabled = false
keychainController.removePINCode()
@@ -94,11 +100,6 @@ class AppLockService: AppLockServiceProtocol {
}
}
/// Ensures that a provided PIN code is long enough and only contains digits.
private func validate(_ pinCode: String) -> Bool {
pinCode.count == 4 && pinCode.allSatisfy(\.isNumber)
}
/// Shared logic for completing an unlock via a PIN or biometry.
private func completeUnlock() -> Bool {
timer.registerUnlock()