Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Experiments/Experiments/ABTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ public enum ABTest: String, CaseIterable {
/// Experiment ref: pbxNRc-1S0-p2
case aaTestLoggedOut = "woocommerceios_explat_aa_test_logged_out_202212_v2"

/// A/B test for the REST API project
/// Experiment ref: pbxNRc-2i4-p2
case applicationPasswordAuthentication = "woocommerceios_login_rest_api_project_202301_v2"

/// Returns a variation for the given experiment
public var variation: Variation {
ExPlat.shared?.experiment(rawValue) ?? .control
Expand All @@ -27,7 +31,7 @@ public enum ABTest: String, CaseIterable {
switch self {
case .aaTestLoggedIn:
return .loggedIn
case .aaTestLoggedOut:
case .aaTestLoggedOut, .applicationPasswordAuthentication:
return .loggedOut
case .null:
return .none
Expand Down
3 changes: 0 additions & 3 deletions Experiments/Experiments/DefaultFeatureFlagService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@ public struct DefaultFeatureFlagService: FeatureFlagService {
return buildConfig == .alpha
case .tapToPayOnIPhone:
return buildConfig == .localDeveloper
case .applicationPasswordAuthenticationForSiteCredentialLogin:
// Enable this to test application password authentication (WIP)
return false
case .domainSettings:
return buildConfig == .localDeveloper || buildConfig == .alpha
default:
Expand Down
4 changes: 0 additions & 4 deletions Experiments/Experiments/FeatureFlag.swift
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,6 @@ public enum FeatureFlag: Int {
/// - Note: The app will ignore this if `performanceMonitoring` is `false`.
case performanceMonitoringViewController

/// Whether application password authentication should be used when a user logs in with site credentials.
///
case applicationPasswordAuthenticationForSiteCredentialLogin

/// Whether to enable domain updates from the settings for a WPCOM site.
///
case domainSettings
Expand Down
10 changes: 4 additions & 6 deletions WooCommerce/Classes/Authentication/AuthenticationManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ class AuthenticationManager: Authentication {
let isWPComMagicLinkPreferredToPassword = featureFlagService.isFeatureFlagEnabled(.loginMagicLinkEmphasis)
let isWPComMagicLinkShownAsSecondaryActionOnPasswordScreen = featureFlagService.isFeatureFlagEnabled(.loginMagicLinkEmphasisM2)
let isStoreCreationMVPEnabled = featureFlagService.isFeatureFlagEnabled(.storeCreationMVP)
// TODO: Replace with A/B experiment
let enableSiteAddressLoginOnly = featureFlagService.isFeatureFlagEnabled(.applicationPasswordAuthenticationForSiteCredentialLogin)
let enableSiteAddressLoginOnly = ABTest.applicationPasswordAuthentication.variation == .treatment
let configuration = WordPressAuthenticatorConfiguration(wpcomClientId: ApiCredentials.dotcomAppId,
wpcomSecret: ApiCredentials.dotcomSecret,
wpcomScheme: ApiCredentials.dotcomAuthScheme,
Expand Down Expand Up @@ -342,8 +341,7 @@ extension AuthenticationManager: WordPressAuthenticatorDelegate {
/// save the site to memory to check for jetpack requirement in epilogue
currentSelfHostedSite = site

// TODO: Replace with A/B experiment
let enableWPComOnlyForWPComSites = featureFlagService.isFeatureFlagEnabled(.applicationPasswordAuthenticationForSiteCredentialLogin)
let enableWPComOnlyForWPComSites = ABTest.applicationPasswordAuthentication.variation == .treatment

switch (enableWPComOnlyForWPComSites, site.isWPCom) {
case (true, true), (false, _):
Expand Down Expand Up @@ -389,7 +387,7 @@ extension AuthenticationManager: WordPressAuthenticatorDelegate {
/// If the user logged in with site credentials and application password feature flag is enabled,
/// check if they can use the app and navigates to the home screen.
if let siteCredentials = credentials.wporg,
featureFlagService.isFeatureFlagEnabled(.applicationPasswordAuthenticationForSiteCredentialLogin) {
ABTest.applicationPasswordAuthentication.variation == .treatment {
return didAuthenticateUser(to: siteURL,
with: siteCredentials,
in: navigationController)
Expand Down Expand Up @@ -501,7 +499,7 @@ extension AuthenticationManager: WordPressAuthenticatorDelegate {
///
func sync(credentials: AuthenticatorCredentials, onCompletion: @escaping () -> Void) {
if let wporg = credentials.wporg,
featureFlagService.isFeatureFlagEnabled(.applicationPasswordAuthenticationForSiteCredentialLogin) {
ABTest.applicationPasswordAuthentication.variation == .treatment {
ServiceLocator.stores.authenticate(credentials: .wporg(username: wporg.username,
password: wporg.password,
siteAddress: wporg.siteURL))
Expand Down