Skip to content

Conversation

@ealeksandrov
Copy link
Contributor

@ealeksandrov ealeksandrov commented Oct 24, 2022

#7911

Description

This PR adds code from WP app to correctly authenticate user in the webview.
We need only atomic and self-hosted sites support, so we don't have to reimplement all the flows.

Video

RPReplay_Final.mp4

@ealeksandrov ealeksandrov added the feature: product details Related to adding or editing products, including Product Settings. label Oct 24, 2022
@ealeksandrov ealeksandrov force-pushed the issue/7911-webview-auth branch from b70c42c to d2091c2 Compare October 25, 2022 17:56
}

extension WebKitViewController: WKUIDelegate {
func webView(_ webView: WKWebView, createWebViewWith configuration: WKWebViewConfiguration, for navigationAction: WKNavigationAction, windowFeatures: WKWindowFeatures) -> WKWebView? {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line Length Violation: Line should be 160 characters or less: currently 187 characters (line_length)

decisionHandler(.allow)
}

func webView(_ webView: WKWebView, decidePolicyFor navigationResponse: WKNavigationResponse, decisionHandler: @escaping (WKNavigationResponsePolicy) -> Void) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line Length Violation: Line should be 160 characters or less: currently 163 characters (line_length)


NSLayoutConstraint.activate(edgeConstraints)

// we are pinning the top and bottom of the stack view to the safe area to prevent unintentionally hidden content/overlaps (ie cookie acceptance popup) then center the horizontal constraints vertically
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line Length Violation: Line should be 160 characters or less: currently 209 characters (line_length)

@wpmobilebot
Copy link
Collaborator

You can test the changes from this Pull Request by:
  • Clicking here or scanning the QR code below to access App Center
  • Then installing the build number pr7924-d2091c2 on your iPhone

If you need access to App Center, please ask a maintainer to add you.

headers.forEach { (key, value) in
request.setValue(value, forHTTPHeaderField: key)
}
// request.setValue(WPUserAgent.wordPress(), forHTTPHeaderField: "User-Agent")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to set up another user agent here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see a reason for that. Nothing changed when I copy-pasted exact user-agent string from WP.
Without explicit setter it will be same as default: WooCommerce/10.8.0.0 CFNetwork/1390 Darwin/22.1.0.

@ealeksandrov
Copy link
Contributor Author

Closing in favor of #7961 + #7974

@ealeksandrov ealeksandrov deleted the issue/7911-webview-auth branch October 28, 2022 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature: product details Related to adding or editing products, including Product Settings.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants