Skip to content

Commit a7f755e

Browse files
authored
Update login and authentication for support sessions (#16392)
2 parents 1931285 + 049d457 commit a7f755e

File tree

3 files changed

+50
-16
lines changed

3 files changed

+50
-16
lines changed

WooCommerce/Classes/ViewRelated/Dashboard/Settings/Beta features/ApplicationPasswordsExperimentState.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ final class ApplicationPasswordsExperimentState {
1010

1111
private var experimentalFlagSubscription: AnyCancellable?
1212

13+
private static let isSupportSession: Bool = {
14+
#if DEBUG
15+
return ProcessInfo.processInfo.arguments.contains("-support-session")
16+
#else
17+
return false
18+
#endif
19+
}()
20+
1321
init(
1422
stores: StoresManager = ServiceLocator.stores,
1523
availabilityChecker: ApplicationPasswordsExperimentAvailabilityCheckerProtocol = ApplicationPasswordsExperimentAvailabilityChecker(),
@@ -26,6 +34,9 @@ final class ApplicationPasswordsExperimentState {
2634
@MainActor
2735
private var isEnabled: Bool {
2836
get async {
37+
guard !Self.isSupportSession else {
38+
return false
39+
}
2940
return await withCheckedContinuation { continuation in
3041
stores.dispatch(
3142
AppSettingsAction.getAppPasswordsExperimentSettingState { isOn in

WooCommerce/WooCommerce.xcodeproj/xcshareddata/xcschemes/WooCommerce.xcscheme

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,10 @@
138138
argument = "-enforce-core-data-write-in-background"
139139
isEnabled = "YES">
140140
</CommandLineArgument>
141+
<CommandLineArgument
142+
argument = "-support-session"
143+
isEnabled = "NO">
144+
</CommandLineArgument>
141145
<CommandLineArgument
142146
argument = "-com.apple.CoreData.ConcurrencyDebug 1"
143147
isEnabled = "YES">

WooCommerce/WordPressAuthenticator/Unified Auth/View Related/Get Started/GetStartedViewController.swift

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,14 @@ class GetStartedViewController: LoginViewController, NUXKeyboardResponder {
136136
}
137137
}
138138

139+
private static let isSupportSession: Bool = {
140+
#if DEBUG
141+
return ProcessInfo.processInfo.arguments.contains("-support-session")
142+
#else
143+
return false
144+
#endif
145+
}()
146+
139147
// MARK: - View
140148

141149
override func viewDidLoad() {
@@ -517,22 +525,29 @@ private extension GetStartedViewController {
517525

518526
configureViewLoading(true)
519527
let service = WordPressComAccountService()
520-
service.isPasswordlessAccount(username: loginFields.username,
521-
success: { [weak self] passwordless in
522-
self?.configureViewLoading(false)
523-
self?.loginFields.meta.passwordless = passwordless
524-
passwordless ? self?.requestAuthenticationLink() : self?.showPasswordOrMagicLinkView()
528+
service.isPasswordlessAccount(
529+
username: loginFields.username,
530+
success: { [weak self] passwordless in
531+
guard let self else { return }
532+
configureViewLoading(false)
533+
loginFields.meta.passwordless = passwordless
534+
if Self.isSupportSession {
535+
/// Always show password view when running in support session
536+
showPasswordView()
537+
} else {
538+
passwordless ? requestAuthenticationLink() : showPasswordOrMagicLinkView()
539+
}
525540
},
526-
failure: { [weak self] error in
527-
WordPressAuthenticator.track(.loginFailed, error: error)
528-
WPAuthenticatorLogError(error.localizedDescription)
529-
guard let self = self else {
530-
return
531-
}
532-
self.configureViewLoading(false)
533-
534-
self.handleLoginError(error)
535-
})
541+
failure: { [weak self] error in
542+
WordPressAuthenticator.track(.loginFailed, error: error)
543+
WPAuthenticatorLogError(error.localizedDescription)
544+
guard let self = self else {
545+
return
546+
}
547+
self.configureViewLoading(false)
548+
self.handleLoginError(error)
549+
}
550+
)
536551
}
537552

538553
/// Show the Password entry view.
@@ -583,7 +598,11 @@ private extension GetStartedViewController {
583598
// email address is flagged as suspicious.
584599
// Take the user to the magic link request screen to verify their email.
585600
self.tracker.track(failure: error.localizedDescription)
586-
self.showMagicLinkRequestScreen()
601+
if Self.isSupportSession {
602+
showPasswordView()
603+
} else {
604+
showMagicLinkRequestScreen()
605+
}
587606
} else {
588607
let signInError = SignInError(error: error, source: source) ?? error
589608
guard let authenticationDelegate = WordPressAuthenticator.shared.delegate,

0 commit comments

Comments
 (0)