Skip to content

Commit 8c8e828

Browse files
committed
Protect againts double initi
1 parent 68923c0 commit 8c8e828

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

WooCommerce/Classes/Authentication/AuthenticationManager.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ class AuthenticationManager: Authentication {
6565

6666
private let userDefaults: UserDefaults
6767

68+
private var initialized: Bool = false
69+
6870
init(stores: StoresManager = ServiceLocator.stores,
6971
storageManager: StorageManagerType = ServiceLocator.storageManager,
7072
featureFlagService: FeatureFlagService = ServiceLocator.featureFlagService,
@@ -84,6 +86,8 @@ class AuthenticationManager: Authentication {
8486
/// Initializes the WordPress Authenticator.
8587
///
8688
func initialize() {
89+
guard !initialized else { return }
90+
initialized = true
8791
WordPressAuthenticator.initializeWithCustomConfigs()
8892
WordPressAuthenticator.shared.delegate = self
8993
}

WooCommerce/Classes/ViewRelated/AppCoordinator.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ private extension AppCoordinator {
238238

239239
/// Configures the WPAuthenticator for usage in both logged-in and logged-out states.
240240
func configureAuthenticator() {
241+
authenticationManager.initialize()
241242
authenticationManager.setLoggedOutAppSettings(loggedOutAppSettings)
242243
authenticationManager.displayAuthenticatorIfLoggedOut = { [weak self] in
243244
guard let self, self.isLoggedIn == false else { return nil }

0 commit comments

Comments
 (0)