Skip to content

Commit 3f712e3

Browse files
committed
Configure authenticator in all app states to avoid crashes in the logged-in state for Apple ID credentials checker.
1 parent 679ea53 commit 3f712e3

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

WooCommerce/Classes/ViewRelated/AppCoordinator.swift

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ final class AppCoordinator {
7373
self.displayLoggedInStateWithoutDefaultStore()
7474
case (true, false):
7575
self.validateRoleEligibility {
76+
self.configureAuthenticator()
7677
self.displayLoggedInUI()
7778
self.synchronizeAndShowWhatsNew()
7879
}
@@ -142,8 +143,8 @@ private extension AppCoordinator {
142143

143144
/// Configures the WPAuthenticator and sets the authenticator UI as the window's root view.
144145
func configureAndDisplayAuthenticator() {
145-
authenticationManager.initialize()
146-
appleIDCredentialChecker.observeLoggedInStateForAppleIDObservations()
146+
configureAuthenticator()
147+
147148
let authenticationUI = authenticationManager.authenticationUI()
148149
setWindowRootViewControllerAndAnimateIfNeeded(authenticationUI) { [weak self] _ in
149150
guard let self = self else { return }
@@ -152,6 +153,12 @@ private extension AppCoordinator {
152153
ServiceLocator.analytics.track(.openedLogin, withProperties: ["prologue_experiment_variant": ABTest.loginPrologueButtonOrder.variation.analyticsValue])
153154
}
154155

156+
/// Configures the WPAuthenticator for usage in both logged-in and logged-out states.
157+
func configureAuthenticator() {
158+
authenticationManager.initialize()
159+
appleIDCredentialChecker.observeLoggedInStateForAppleIDObservations()
160+
}
161+
155162
/// Determines whether the login onboarding should be shown.
156163
func canPresentLoginOnboarding() -> Bool {
157164
// Since we cannot control the user defaults in the simulator where UI tests are run on,
@@ -209,6 +216,8 @@ private extension AppCoordinator {
209216
return
210217
}
211218

219+
configureAuthenticator()
220+
212221
let matcher = ULAccountMatcher(storageManager: storageManager)
213222
matcher.refreshStoredSites()
214223

0 commit comments

Comments
 (0)