Skip to content
This repository was archived by the owner on Feb 5, 2025. It is now read-only.

Commit 13ef1a8

Browse files
authored
Merge pull request #711 from wordpress-mobile/wcios/optional-xmlrpc-to-verify-wpcom-email
Make XMLRPC URL optional when verifying WP.com email and new config for skipping XMLRPC for site discovery
2 parents 70ac422 + 46567ac commit 13ef1a8

File tree

5 files changed

+17
-9
lines changed

5 files changed

+17
-9
lines changed

Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ PODS:
2828
- SVProgressHUD (2.2.5)
2929
- SwiftLint (0.49.1)
3030
- UIDeviceIdentifier (1.6.0)
31-
- WordPressAuthenticator (4.2.0):
31+
- WordPressAuthenticator (4.3.0-beta.1):
3232
- CocoaLumberjack (~> 3.5)
3333
- GoogleSignIn (~> 6.0.1)
3434
- Gridicons (~> 1.0)
@@ -109,7 +109,7 @@ SPEC CHECKSUMS:
109109
SVProgressHUD: 1428aafac632c1f86f62aa4243ec12008d7a51d6
110110
SwiftLint: 32ee33ded0636d0905ef6911b2b67bbaeeedafa5
111111
UIDeviceIdentifier: f4bf3b343581a1beacdbf5fb1a8825bd5f05a4a4
112-
WordPressAuthenticator: 3bbb0a33f2c1d7bda353bd123aba60b4a237b235
112+
WordPressAuthenticator: 6ef20b546ac4f90e7ff3452979e19f6167e9f605
113113
WordPressKit: ee58e3d313ddce1f768e87d76364d261ad86fca9
114114
WordPressShared: 38cb62e9cb998d4dc3c1611f17934c6875a6b3e8
115115
WordPressUI: 1cf47a3b78154faf69caa18569ee7ece1e510fa0

WordPressAuthenticator.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Pod::Spec.new do |s|
44
s.name = 'WordPressAuthenticator'
5-
s.version = '4.2.0'
5+
s.version = '4.3.0-beta.1'
66

77
s.summary = 'WordPressAuthenticator implements an easy and elegant way to authenticate your WordPress Apps.'
88
s.description = <<-DESC

WordPressAuthenticator/Authenticator/WordPressAuthenticator.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -211,12 +211,8 @@ import WordPressKit
211211
/// - siteURL: The URL of the site to log in to.
212212
///
213213
@objc public class func showVerifyEmailForWPCom(from presenter: UIViewController, xmlrpc: String, connectedEmail: String, siteURL: String) {
214-
guard let xmlrpcURL = URL(string: xmlrpc) else {
215-
DDLogError("Failed to initiate XML-RPC URL from \(xmlrpc)")
216-
return
217-
}
218214
let loginFields = LoginFields()
219-
loginFields.meta.xmlrpcURL = xmlrpcURL as NSURL
215+
loginFields.meta.xmlrpcURL = NSURL(string: xmlrpc)
220216
loginFields.username = connectedEmail
221217
loginFields.siteAddress = siteURL
222218

WordPressAuthenticator/Authenticator/WordPressAuthenticatorConfiguration.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ public struct WordPressAuthenticatorConfiguration {
132132
///
133133
let wpcomPasswordInstructions: String?
134134

135+
/// If enabled, site discovery will not check for XMLRPC URL.
136+
///
137+
let skipXMLRPCCheckForSiteDiscovery: Bool
138+
135139
/// Designated Initializer
136140
///
137141
public init (wpcomClientId: String,
@@ -161,7 +165,8 @@ public struct WordPressAuthenticatorConfiguration {
161165
enableSiteCreation: Bool = false,
162166
enableSocialLogin: Bool = false,
163167
emphasizeEmailForWPComPassword: Bool = false,
164-
wpcomPasswordInstructions: String? = nil) {
168+
wpcomPasswordInstructions: String? = nil,
169+
skipXMLRPCCheckForSiteDiscovery: Bool = false) {
165170

166171
self.wpcomClientId = wpcomClientId
167172
self.wpcomSecret = wpcomSecret
@@ -191,5 +196,6 @@ public struct WordPressAuthenticatorConfiguration {
191196
self.enableSocialLogin = enableSocialLogin
192197
self.emphasizeEmailForWPComPassword = emphasizeEmailForWPComPassword
193198
self.wpcomPasswordInstructions = wpcomPasswordInstructions
199+
self.skipXMLRPCCheckForSiteDiscovery = skipXMLRPCCheckForSiteDiscovery
194200
}
195201
}

WordPressAuthenticator/Unified Auth/View Related/Site Address/SiteAddressViewController.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ final class SiteAddressViewController: LoginViewController {
3131
/// Whether the protocol method `troubleshootSite` should be triggered after site info is fetched.
3232
///
3333
private let isSiteDiscovery: Bool
34+
private let configuration = WordPressAuthenticator.shared.configuration
3435

3536
init?(isSiteDiscovery: Bool, coder: NSCoder) {
3637
self.isSiteDiscovery = isSiteDiscovery
@@ -442,6 +443,11 @@ private extension SiteAddressViewController {
442443
// Checks that the site exists
443444
checkSiteExistence(url: url) { [weak self] in
444445
guard let self = self else { return }
446+
// skips XMLRPC check for site discovery if needed
447+
if self.isSiteDiscovery && self.configuration.skipXMLRPCCheckForSiteDiscovery {
448+
self.fetchSiteInfo()
449+
return
450+
}
445451
// Proceeds to check for the site's WordPress
446452
self.guessXMLRPCURL(for: self.loginFields.siteAddress)
447453
}

0 commit comments

Comments
 (0)