Make LinkNewDeviceScreen fall back to the App Lock PIN code when there's no passcode. (#5794)

* Fall back to the AppLock PIN code when there's no passcode.

* Add extra tests on the LinkNewDeviceFlowCoordinator.

* Misc tweaks for clarification.

* Regenerate snapshots.
This commit is contained in:
Doug
2026-07-01 10:13:18 +01:00
committed by GitHub
parent 7097ceb910
commit 123661537a
38 changed files with 296 additions and 21 deletions
@@ -11,6 +11,7 @@ import SwiftUI
enum LinkNewDeviceScreenCoordinatorAction {
case linkMobileDevice(LinkNewDeviceService.LinkMobileProgressPublisher)
case linkDesktopComputer
case verifyWithAppLockPIN(CheckedContinuation<Bool, Never>)
case dismiss
}
@@ -47,6 +48,8 @@ final class LinkNewDeviceScreenCoordinator: CoordinatorProtocol {
actionsSubject.send(.linkMobileDevice(progressPublisher))
case .linkDesktopComputer:
actionsSubject.send(.linkDesktopComputer)
case .verifyWithAppLockPIN(let continuation):
actionsSubject.send(.verifyWithAppLockPIN(continuation))
case .dismiss:
actionsSubject.send(.dismiss)
}
@@ -10,6 +10,7 @@ import Foundation
enum LinkNewDeviceScreenViewModelAction {
case linkMobileDevice(LinkNewDeviceService.LinkMobileProgressPublisher)
case linkDesktopComputer
case verifyWithAppLockPIN(CheckedContinuation<Bool, Never>)
case dismiss
}
@@ -72,8 +72,10 @@ class LinkNewDeviceScreenViewModel: LinkNewDeviceScreenViewModelType, LinkNewDev
case .verified, .unavailable:
break
case .appLockPINRequired:
// Follow-up PR: present the App Lock PIN screen to verify the device owner.
return
guard await verifyWithAppLockPIN() else {
state.mode = .readyToLink(.idle)
return
}
case .cancelled, .unverified:
state.mode = .readyToLink(.idle)
return
@@ -92,6 +94,13 @@ class LinkNewDeviceScreenViewModel: LinkNewDeviceScreenViewModelType, LinkNewDev
}
}
/// Asks the coordinator to verify the device owner with the App Lock PIN, suspending until it has a result.
private func verifyWithAppLockPIN() async -> Bool {
await withCheckedContinuation { continuation in
actionsSubject.send(.verifyWithAppLockPIN(continuation))
}
}
private func linkMobileDevice() async {
state.mode = .readyToLink(.generatingCode)