From 580f1042333c6d74931461ba8c31ac83499781ef Mon Sep 17 00:00:00 2001 From: Huong Do Date: Tue, 25 Nov 2025 17:11:38 +0700 Subject: [PATCH 1/2] Update settings for support session --- .../ApplicationPasswordsExperimentState.swift | 11 ++++ .../xcschemes/WooCommerce.xcscheme | 4 ++ .../GetStartedViewController.swift | 52 +++++++++++++------ 3 files changed, 51 insertions(+), 16 deletions(-) diff --git a/WooCommerce/Classes/ViewRelated/Dashboard/Settings/Beta features/ApplicationPasswordsExperimentState.swift b/WooCommerce/Classes/ViewRelated/Dashboard/Settings/Beta features/ApplicationPasswordsExperimentState.swift index f4b36b04fe3..82c88296045 100644 --- a/WooCommerce/Classes/ViewRelated/Dashboard/Settings/Beta features/ApplicationPasswordsExperimentState.swift +++ b/WooCommerce/Classes/ViewRelated/Dashboard/Settings/Beta features/ApplicationPasswordsExperimentState.swift @@ -65,12 +65,23 @@ final class ApplicationPasswordsExperimentAvailabilityChecker: ApplicationPasswo private let userDefaults: UserDefaults private let stores: StoresManager + private static let isSupportSession: Bool = { + #if DEBUG + return ProcessInfo.processInfo.arguments.contains("-support-session") + #else + return false + #endif + }() + init(userDefaults: UserDefaults = .standard, stores: StoresManager = ServiceLocator.stores) { self.userDefaults = userDefaults self.stores = stores } var isAvailable: Bool { + guard !Self.isSupportSession else { + return false + } /// The feature is only available when the user is signed in using WordPress.com account let isUserAuthenticatedByWPCom = !stores.isAuthenticatedWithoutWPCom return isUserAuthenticatedByWPCom && cachedRemoteFFValue diff --git a/WooCommerce/WooCommerce.xcodeproj/xcshareddata/xcschemes/WooCommerce.xcscheme b/WooCommerce/WooCommerce.xcodeproj/xcshareddata/xcschemes/WooCommerce.xcscheme index 6701467249d..7a31919c6f2 100644 --- a/WooCommerce/WooCommerce.xcodeproj/xcshareddata/xcschemes/WooCommerce.xcscheme +++ b/WooCommerce/WooCommerce.xcodeproj/xcshareddata/xcschemes/WooCommerce.xcscheme @@ -138,6 +138,10 @@ argument = "-enforce-core-data-write-in-background" isEnabled = "YES"> + + diff --git a/WooCommerce/WordPressAuthenticator/Unified Auth/View Related/Get Started/GetStartedViewController.swift b/WooCommerce/WordPressAuthenticator/Unified Auth/View Related/Get Started/GetStartedViewController.swift index bdee916c36c..dcc9f820625 100644 --- a/WooCommerce/WordPressAuthenticator/Unified Auth/View Related/Get Started/GetStartedViewController.swift +++ b/WooCommerce/WordPressAuthenticator/Unified Auth/View Related/Get Started/GetStartedViewController.swift @@ -136,6 +136,14 @@ class GetStartedViewController: LoginViewController, NUXKeyboardResponder { } } + private static let isSupportSession: Bool = { + #if DEBUG + return ProcessInfo.processInfo.arguments.contains("-support-session") + #else + return false + #endif + }() + // MARK: - View override func viewDidLoad() { @@ -517,22 +525,30 @@ private extension GetStartedViewController { configureViewLoading(true) let service = WordPressComAccountService() - service.isPasswordlessAccount(username: loginFields.username, - success: { [weak self] passwordless in - self?.configureViewLoading(false) - self?.loginFields.meta.passwordless = passwordless - passwordless ? self?.requestAuthenticationLink() : self?.showPasswordOrMagicLinkView() + service.isPasswordlessAccount( + username: loginFields.username, + success: { [weak self] passwordless in + guard let self else { return } + configureViewLoading(false) + loginFields.meta.passwordless = passwordless + if Self.isSupportSession { + /// Always show password view when running in support session + showPasswordView() + } else { + passwordless ? requestAuthenticationLink() : showPasswordOrMagicLinkView() + } }, - failure: { [weak self] error in - WordPressAuthenticator.track(.loginFailed, error: error) - WPAuthenticatorLogError(error.localizedDescription) - guard let self = self else { - return - } - self.configureViewLoading(false) - - self.handleLoginError(error) - }) + failure: { [weak self] error in + WordPressAuthenticator.track(.loginFailed, error: error) + WPAuthenticatorLogError(error.localizedDescription) + guard let self = self else { + return + } + self.configureViewLoading(false) + + self.handleLoginError(error) + } + ) } /// Show the Password entry view. @@ -583,7 +599,11 @@ private extension GetStartedViewController { // email address is flagged as suspicious. // Take the user to the magic link request screen to verify their email. self.tracker.track(failure: error.localizedDescription) - self.showMagicLinkRequestScreen() + if Self.isSupportSession { + showPasswordView() + } else { + showMagicLinkRequestScreen() + } } else { let signInError = SignInError(error: error, source: source) ?? error guard let authenticationDelegate = WordPressAuthenticator.shared.delegate, From 049d4574d740ebee85487c616d3e2666288212fa Mon Sep 17 00:00:00 2001 From: Huong Do Date: Tue, 25 Nov 2025 17:41:33 +0700 Subject: [PATCH 2/2] Move support session check to ApplicationPasswordsExperimentState --- .../ApplicationPasswordsExperimentState.swift | 22 +++++++++---------- .../GetStartedViewController.swift | 1 - 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/WooCommerce/Classes/ViewRelated/Dashboard/Settings/Beta features/ApplicationPasswordsExperimentState.swift b/WooCommerce/Classes/ViewRelated/Dashboard/Settings/Beta features/ApplicationPasswordsExperimentState.swift index 82c88296045..a1670485039 100644 --- a/WooCommerce/Classes/ViewRelated/Dashboard/Settings/Beta features/ApplicationPasswordsExperimentState.swift +++ b/WooCommerce/Classes/ViewRelated/Dashboard/Settings/Beta features/ApplicationPasswordsExperimentState.swift @@ -10,6 +10,14 @@ final class ApplicationPasswordsExperimentState { private var experimentalFlagSubscription: AnyCancellable? + private static let isSupportSession: Bool = { + #if DEBUG + return ProcessInfo.processInfo.arguments.contains("-support-session") + #else + return false + #endif + }() + init( stores: StoresManager = ServiceLocator.stores, availabilityChecker: ApplicationPasswordsExperimentAvailabilityCheckerProtocol = ApplicationPasswordsExperimentAvailabilityChecker(), @@ -26,6 +34,9 @@ final class ApplicationPasswordsExperimentState { @MainActor private var isEnabled: Bool { get async { + guard !Self.isSupportSession else { + return false + } return await withCheckedContinuation { continuation in stores.dispatch( AppSettingsAction.getAppPasswordsExperimentSettingState { isOn in @@ -65,23 +76,12 @@ final class ApplicationPasswordsExperimentAvailabilityChecker: ApplicationPasswo private let userDefaults: UserDefaults private let stores: StoresManager - private static let isSupportSession: Bool = { - #if DEBUG - return ProcessInfo.processInfo.arguments.contains("-support-session") - #else - return false - #endif - }() - init(userDefaults: UserDefaults = .standard, stores: StoresManager = ServiceLocator.stores) { self.userDefaults = userDefaults self.stores = stores } var isAvailable: Bool { - guard !Self.isSupportSession else { - return false - } /// The feature is only available when the user is signed in using WordPress.com account let isUserAuthenticatedByWPCom = !stores.isAuthenticatedWithoutWPCom return isUserAuthenticatedByWPCom && cachedRemoteFFValue diff --git a/WooCommerce/WordPressAuthenticator/Unified Auth/View Related/Get Started/GetStartedViewController.swift b/WooCommerce/WordPressAuthenticator/Unified Auth/View Related/Get Started/GetStartedViewController.swift index dcc9f820625..0dd289032c8 100644 --- a/WooCommerce/WordPressAuthenticator/Unified Auth/View Related/Get Started/GetStartedViewController.swift +++ b/WooCommerce/WordPressAuthenticator/Unified Auth/View Related/Get Started/GetStartedViewController.swift @@ -545,7 +545,6 @@ private extension GetStartedViewController { return } self.configureViewLoading(false) - self.handleLoginError(error) } )