Skip to content

Commit 00b21cc

Browse files
committed
Update Jetpack connection for flow from login
1 parent 90468b2 commit 00b21cc

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

WooCommerce/Classes/Authentication/Jetpack Setup/LoginJetpackSetupCoordinator.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ final class LoginJetpackSetupCoordinator: Coordinator {
4444
//
4545
private extension LoginJetpackSetupCoordinator {
4646
func showSetupSteps() {
47-
let setupUI = JetpackSetupHostingController(siteURL: siteURL, connectionOnly: connectionOnly, onStoreNavigation: { [weak self] connectedEmail in
47+
let setupUI = JetpackSetupHostingController(
48+
siteURL: siteURL,
49+
connectionOnly: connectionOnly,
50+
wpcomCredentials: stores.sessionManager.defaultCredentials,
51+
onStoreNavigation: { [weak self] connectedEmail in
4852
guard let self, let email = connectedEmail else { return }
4953
if email != self.stores.sessionManager.defaultAccount?.email {
5054
// if the user authorized Jetpack with a different account, support them to log in with that account.

WooCommerce/Classes/Authentication/Jetpack Setup/Native Jetpack Setup/JetpackSetupView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ final class JetpackSetupHostingController: UIHostingController<JetpackSetupView>
1111

1212
init(siteURL: String,
1313
connectionOnly: Bool,
14-
wpcomCredentials: Credentials? = nil,
14+
wpcomCredentials: Credentials?,
1515
stores: StoresManager = ServiceLocator.stores,
1616
authentication: Authentication = ServiceLocator.authenticationManager,
1717
analytics: Analytics = ServiceLocator.analytics,

WooCommerce/Classes/Authentication/Jetpack Setup/Native Jetpack Setup/JetpackSetupViewModel.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,8 +450,10 @@ private extension JetpackSetupViewModel {
450450
}
451451

452452
func finalizeSiteConnection(blogID: Int64, provisionResponse: JetpackConnectionProvisionResponse) {
453-
guard let wpcomCredentials else {
454-
return // TODO: what now?
453+
guard let wpcomCredentials, case .wpcom = wpcomCredentials else {
454+
/// WPCom credentials are necessary to finalize connection through API
455+
/// If this is unavailable, fall back to the web flow.
456+
return fetchJetpackConnectionURL()
455457
}
456458
let network = AlamofireNetwork(credentials: wpcomCredentials)
457459
stores.dispatch(JetpackConnectionAction.finalizeConnection(

0 commit comments

Comments
 (0)