mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:33:26 +00:00
Add AppLockSetupPINScreen. (#1930)
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user