Skip to content

Commit a714aa2

Browse files
committed
Use authenticated WebKitViewController to handle product previews
1 parent ccffa93 commit a714aa2

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

WooCommerce/Classes/ViewRelated/Products/Edit Product/ProductFormViewController.swift

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,17 @@ final class ProductFormViewController<ViewModel: ProductFormViewModelProtocol>:
223223
return
224224
}
225225

226-
// TODO: Show authenticated WebView
227-
WebviewHelper.launch(url, with: self)
226+
let credentials = ServiceLocator.stores.sessionManager.defaultCredentials
227+
guard let username = credentials?.username,
228+
let token = credentials?.authToken,
229+
let site = ServiceLocator.stores.sessionManager.defaultSite else {
230+
return
231+
}
232+
233+
let configuration = WebViewControllerConfiguration(url: url)
234+
configuration.authenticate(site: site, username: username, token: token)
235+
let vc = WebKitViewController(configuration: configuration)
236+
present(vc, animated: true)
228237
}
229238

230239
// MARK: Navigation actions

0 commit comments

Comments
 (0)