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

Commit ceaffe8

Browse files
authored
Merge pull request #71 from wordpress-mobile/task/wc-support-site-url-login
WCiOS: Support Site URL login
2 parents d5511c7 + fa3fdaa commit ceaffe8

20 files changed

+788
-99
lines changed

WordPressAuthenticator.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "WordPressAuthenticator"
3-
s.version = "1.2.1"
3+
s.version = "1.3.0-beta.1"
44
s.summary = "WordPressAuthenticator implements an easy and elegant way to authenticate your WordPress Apps."
55

66
s.description = <<-DESC

WordPressAuthenticator.xcodeproj/project.pbxproj

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,13 @@
9999
CE16177521B6D82200B82A47 /* WordPressAuthenticatorDisplayStrings.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE16177421B6D82200B82A47 /* WordPressAuthenticatorDisplayStrings.swift */; };
100100
CE16177821B70C1A00B82A47 /* WordPressAuthenticatorDisplayTextTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE16177721B70C1A00B82A47 /* WordPressAuthenticatorDisplayTextTests.swift */; };
101101
CE1B18C920EEC2C200BECC3F /* SocialService.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE1B18C820EEC2C200BECC3F /* SocialService.swift */; };
102-
CE1B18CC20EEC32400BECC3F /* WordPressCredentials.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE1B18CB20EEC32400BECC3F /* WordPressCredentials.swift */; };
102+
CE1B18CC20EEC32400BECC3F /* WordPressComCredentials.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE1B18CB20EEC32400BECC3F /* WordPressComCredentials.swift */; };
103103
CE1B18CE20EEC3CB00BECC3F /* WordPressAuthenticatorDelegateProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE1B18CD20EEC3CB00BECC3F /* WordPressAuthenticatorDelegateProtocol.swift */; };
104104
CE1B18D020EEC41600BECC3F /* WordPressAuthenticatorConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE1B18CF20EEC41600BECC3F /* WordPressAuthenticatorConfiguration.swift */; };
105105
CE1B18D220EEC44400BECC3F /* WordPressAuthenticatorStyles.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE1B18D120EEC44400BECC3F /* WordPressAuthenticatorStyles.swift */; };
106+
CE30A2A722579F4100DF3CDA /* LoginUsernamePasswordViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE30A2A622579F4100DF3CDA /* LoginUsernamePasswordViewController.swift */; };
107+
CE30A2A92257C60500DF3CDA /* WordPressOrgCredentials.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE30A2A82257C60500DF3CDA /* WordPressOrgCredentials.swift */; };
108+
CE30A2AD2257CECC00DF3CDA /* AuthenticatorCredentials.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE30A2AC2257CECC00DF3CDA /* AuthenticatorCredentials.swift */; };
106109
E8AF6B9EF50902F2117DFAF9 /* Pods_WordPressAuthenticatorTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5A441EC80D2B8D2209C2E228 /* Pods_WordPressAuthenticatorTests.framework */; };
107110
FF629D9622393500004C4106 /* WordPressAuthenticator.podspec in Resources */ = {isa = PBXBuildFile; fileRef = FF629D9522393500004C4106 /* WordPressAuthenticator.podspec */; };
108111
/* End PBXBuildFile section */
@@ -240,10 +243,13 @@
240243
CE16177421B6D82200B82A47 /* WordPressAuthenticatorDisplayStrings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WordPressAuthenticatorDisplayStrings.swift; sourceTree = "<group>"; };
241244
CE16177721B70C1A00B82A47 /* WordPressAuthenticatorDisplayTextTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WordPressAuthenticatorDisplayTextTests.swift; sourceTree = "<group>"; };
242245
CE1B18C820EEC2C200BECC3F /* SocialService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SocialService.swift; sourceTree = "<group>"; };
243-
CE1B18CB20EEC32400BECC3F /* WordPressCredentials.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WordPressCredentials.swift; sourceTree = "<group>"; };
246+
CE1B18CB20EEC32400BECC3F /* WordPressComCredentials.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WordPressComCredentials.swift; sourceTree = "<group>"; };
244247
CE1B18CD20EEC3CB00BECC3F /* WordPressAuthenticatorDelegateProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WordPressAuthenticatorDelegateProtocol.swift; sourceTree = "<group>"; };
245248
CE1B18CF20EEC41600BECC3F /* WordPressAuthenticatorConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WordPressAuthenticatorConfiguration.swift; sourceTree = "<group>"; };
246249
CE1B18D120EEC44400BECC3F /* WordPressAuthenticatorStyles.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WordPressAuthenticatorStyles.swift; sourceTree = "<group>"; };
250+
CE30A2A622579F4100DF3CDA /* LoginUsernamePasswordViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LoginUsernamePasswordViewController.swift; sourceTree = "<group>"; };
251+
CE30A2A82257C60500DF3CDA /* WordPressOrgCredentials.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WordPressOrgCredentials.swift; sourceTree = "<group>"; };
252+
CE30A2AC2257CECC00DF3CDA /* AuthenticatorCredentials.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthenticatorCredentials.swift; sourceTree = "<group>"; };
247253
E9414A95E29F3297555AC92B /* Pods-WordPressAuthenticator.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WordPressAuthenticator.debug.xcconfig"; path = "Pods/Target Support Files/Pods-WordPressAuthenticator/Pods-WordPressAuthenticator.debug.xcconfig"; sourceTree = "<group>"; };
248254
FF475C5056EB60A277696BA9 /* Pods-WordPressAuthenticatorTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WordPressAuthenticatorTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-WordPressAuthenticatorTests/Pods-WordPressAuthenticatorTests.release.xcconfig"; sourceTree = "<group>"; };
249255
FF629D9522393500004C4106 /* WordPressAuthenticator.podspec */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WordPressAuthenticator.podspec; sourceTree = "<group>"; };
@@ -339,6 +345,7 @@
339345
B5609127208A563600399AE4 /* LoginSiteAddressViewController.swift */,
340346
B560912F208A563700399AE4 /* LoginSocialErrorCell.swift */,
341347
B5609132208A563700399AE4 /* LoginSocialErrorViewController.swift */,
348+
CE30A2A622579F4100DF3CDA /* LoginUsernamePasswordViewController.swift */,
342349
B5609134208A563700399AE4 /* LoginViewController.swift */,
343350
B5609124208A563600399AE4 /* LoginWPComViewController.swift */,
344351
B560912D208A563700399AE4 /* SigninEditingState.swift */,
@@ -543,7 +550,9 @@
543550
CE1B18CA20EEC31000BECC3F /* Credentials */ = {
544551
isa = PBXGroup;
545552
children = (
546-
CE1B18CB20EEC32400BECC3F /* WordPressCredentials.swift */,
553+
CE1B18CB20EEC32400BECC3F /* WordPressComCredentials.swift */,
554+
CE30A2A82257C60500DF3CDA /* WordPressOrgCredentials.swift */,
555+
CE30A2AC2257CECC00DF3CDA /* AuthenticatorCredentials.swift */,
547556
);
548557
path = Credentials;
549558
sourceTree = "<group>";
@@ -833,7 +842,7 @@
833842
B5609143208A563800399AE4 /* LoginSocialErrorViewController.swift in Sources */,
834843
B56090F8208A533200399AE4 /* WordPressAuthenticator+Notifications.swift in Sources */,
835844
B56090EA208A51D000399AE4 /* LoginFields+Validation.swift in Sources */,
836-
CE1B18CC20EEC32400BECC3F /* WordPressCredentials.swift in Sources */,
845+
CE1B18CC20EEC32400BECC3F /* WordPressComCredentials.swift in Sources */,
837846
98AA5A5720AA1A7000A5958A /* WPHelpIndicatorView.swift in Sources */,
838847
B560913C208A563800399AE4 /* LoginProloguePromoViewController.swift in Sources */,
839848
B560910F208A54F800399AE4 /* SafariCredentialsService.swift in Sources */,
@@ -848,6 +857,7 @@
848857
B5ED7920207E993E00A8FD8C /* WPAuthenticatorLogging.m in Sources */,
849858
B5609138208A563800399AE4 /* LoginSiteAddressViewController.swift in Sources */,
850859
B560910B208A54F800399AE4 /* LoginFacade.m in Sources */,
860+
CE30A2AD2257CECC00DF3CDA /* AuthenticatorCredentials.swift in Sources */,
851861
B5609145208A563800399AE4 /* LoginViewController.swift in Sources */,
852862
B5609139208A563800399AE4 /* LoginEmailViewController.swift in Sources */,
853863
B56090F9208A533200399AE4 /* WordPressAuthenticator+Events.swift in Sources */,
@@ -877,6 +887,8 @@
877887
B5ED791F207E993E00A8FD8C /* CocoaLumberjack.swift in Sources */,
878888
B5609123208A557700399AE4 /* WordPressComSiteInfo.swift in Sources */,
879889
B56090CC208A4F5400399AE4 /* NUXTableViewController.swift in Sources */,
890+
CE30A2A722579F4100DF3CDA /* LoginUsernamePasswordViewController.swift in Sources */,
891+
CE30A2A92257C60500DF3CDA /* WordPressOrgCredentials.swift in Sources */,
880892
B56090CB208A4F5400399AE4 /* NUXNavigationController.swift in Sources */,
881893
B560911F208A555E00399AE4 /* SignupGoogleViewController.swift in Sources */,
882894
B5609142208A563800399AE4 /* LoginNavigationController.swift in Sources */,

WordPressAuthenticator/Authenticator/WordPressAuthenticator.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,15 +211,14 @@ import WordPressUI
211211
}
212212

213213

214-
/// Returns an instance of LoginEmailViewController. This allows the host app to fine tune the way it's displayed / configure
215-
/// it's features.
214+
/// Returns an instance of LoginEmailViewController.
215+
/// This allows the host app to configure the controller's features.
216216
///
217217
public class func signinForWPCom() -> LoginEmailViewController {
218218
let storyboard = UIStoryboard(name: "Login", bundle: bundle)
219219
guard let controller = storyboard.instantiateViewController(withIdentifier: "emailEntry") as? LoginEmailViewController else {
220220
fatalError()
221221
}
222-
controller.loginFields.restrictToWPCom = true
223222

224223
return controller
225224
}

WordPressAuthenticator/Authenticator/WordPressAuthenticatorDelegateProtocol.swift

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,21 @@ public protocol WordPressAuthenticatorDelegate: class {
3636
///
3737
func presentSupportRequest(from sourceViewController: UIViewController, sourceTag: WordPressSupportSourceTag)
3838

39+
/// Signals to the Host App that a WordPress site is available and needs validated
40+
/// before presenting the username and password view controller.
41+
/// - Parameters:
42+
/// - site: passes in the site information to the delegate method.
43+
/// - onCompletion: Closure to be executed on completion.
44+
///
45+
func shouldPresentUsernamePasswordController(for siteInfo: WordPressComSiteInfo?, onCompletion: @escaping (Error?, Bool) -> Void)
46+
3947
/// Presents the Login Epilogue, in the specified NavigationController.
4048
///
41-
func presentLoginEpilogue(in navigationController: UINavigationController, for credentials: WordPressCredentials, onDismiss: @escaping () -> Void)
49+
func presentLoginEpilogue(in navigationController: UINavigationController, for credentials: AuthenticatorCredentials, onDismiss: @escaping () -> Void)
4250

4351
/// Presents the Login Epilogue, in the specified NavigationController.
4452
///
45-
func presentSignupEpilogue(in navigationController: UINavigationController, for credentials: WordPressCredentials, service: SocialService?)
53+
func presentSignupEpilogue(in navigationController: UINavigationController, for credentials: AuthenticatorCredentials, service: SocialService?)
4654

4755
/// Presents the Support Interface from a given ViewController, with a specified SourceTag.
4856
///
@@ -64,7 +72,7 @@ public protocol WordPressAuthenticatorDelegate: class {
6472
/// - credentials: WordPress Site Credentials.
6573
/// - onCompletion: Closure to be executed on completion.
6674
///
67-
func sync(credentials: WordPressCredentials, onCompletion: @escaping () -> Void)
75+
func sync(credentials: AuthenticatorCredentials, onCompletion: @escaping () -> Void)
6876

6977
/// Signals the Host App that a given Analytics Event has occurred.
7078
///

WordPressAuthenticator/Authenticator/WordPressSupportSourceTag.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ extension WordPressSupportSourceTag {
3939
public static var loginUsernamePassword: WordPressSupportSourceTag {
4040
return WordPressSupportSourceTag(name: "loginUsernamePassword", origin: "origin:login-username-password")
4141
}
42+
public static var loginWPComUsernamePassword: WordPressSupportSourceTag {
43+
return WordPressSupportSourceTag(name: "loginWPComUsernamePassword", origin: "origin:wpcom-login-username-password")
44+
}
4245
public static var loginWPComPassword: WordPressSupportSourceTag {
4346
return WordPressSupportSourceTag(name: "loginWPComPassword", origin: "origin:login-wpcom-password")
4447
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import Foundation
2+
3+
// MARK: - Authenticator Credentials
4+
//
5+
public struct AuthenticatorCredentials {
6+
/// WordPress.com credentials
7+
///
8+
public let wpcom: WordPressComCredentials?
9+
10+
/// Self-hosted site credentials
11+
///
12+
public let wporg: WordPressOrgCredentials?
13+
14+
/// Designated initializer
15+
///
16+
public init(wpcom: WordPressComCredentials? = nil, wporg: WordPressOrgCredentials? = nil) {
17+
self.wpcom = wpcom
18+
self.wporg = wporg
19+
}
20+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import Foundation
2+
3+
// MARK: - WordPress.com Credentials
4+
//
5+
public struct WordPressComCredentials: Equatable {
6+
7+
/// WordPress.com authentication token
8+
///
9+
public let authToken: String
10+
11+
/// Is this a Jetpack-connected site?
12+
///
13+
public let isJetpackLogin: Bool
14+
15+
/// Is 2-factor Authentication Enabled?
16+
///
17+
public let multifactor: Bool
18+
19+
/// The site address used during login
20+
///
21+
public var siteURL: String
22+
23+
/// Designated initializer
24+
///
25+
public init(authToken: String,
26+
isJetpackLogin: Bool,
27+
multifactor: Bool,
28+
siteURL: String) {
29+
self.authToken = authToken
30+
self.isJetpackLogin = isJetpackLogin
31+
self.multifactor = multifactor
32+
self.siteURL = !siteURL.isEmpty ? siteURL : "https://wordpress.com"
33+
}
34+
}
35+
36+
37+
// MARK: - Equatable Conformance
38+
//
39+
public func ==(lhs: WordPressComCredentials, rhs: WordPressComCredentials) -> Bool {
40+
return lhs.authToken == rhs.authToken && lhs.siteURL == rhs.siteURL
41+
}

WordPressAuthenticator/Credentials/WordPressCredentials.swift

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import Foundation
2+
3+
// MARK: - WordPress.org (aka self-hosted site) Credentials
4+
//
5+
public struct WordPressOrgCredentials: Equatable {
6+
/// Self-hosted login username.
7+
/// The one used in the /wp-admin/ panel.
8+
///
9+
public let username: String
10+
11+
/// Self-hosted login password.
12+
/// The one used in the /wp-admin/ panel.
13+
///
14+
public let password: String
15+
16+
/// The URL to reach the XMLRPC file.
17+
/// e.g.: https://exmaple.com/xmlrpc.php
18+
///
19+
public let xmlrpc: String
20+
21+
/// Self-hosted site options
22+
///
23+
public let options: [AnyHashable: Any]
24+
25+
/// Designated initializer
26+
///
27+
public init(username: String, password: String, xmlrpc: String, options: [AnyHashable: Any]) {
28+
self.username = username
29+
self.password = password
30+
self.xmlrpc = xmlrpc
31+
self.options = options
32+
}
33+
}
34+
35+
36+
// MARK: - Equatable Conformance
37+
//
38+
public func ==(lhs: WordPressOrgCredentials, rhs: WordPressOrgCredentials) -> Bool {
39+
return lhs.username == rhs.username && lhs.password == rhs.password && lhs.xmlrpc == rhs.xmlrpc
40+
}

WordPressAuthenticator/Model/WordPressComSiteInfo.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,33 @@ import Foundation
33

44
// MARK: - WordPress.com Site Info
55
//
6-
class WordPressComSiteInfo {
6+
public class WordPressComSiteInfo {
77

88
/// Site's Name!
99
///
10-
let name: String
10+
public let name: String
1111

1212
/// Tagline.
1313
///
14-
let tagline: String
14+
public let tagline: String
1515

1616
/// Public URL.
1717
///
18-
let url: String
18+
public let url: String
1919

2020
/// Indicates if Jetpack is available, or not,
2121
///
22-
let hasJetpack: Bool
22+
public let hasJetpack: Bool
2323

2424
/// URL of the Site's Blavatar.
2525
///
26-
let icon: String
26+
public let icon: String
2727

2828

2929

3030
/// Initializes the current SiteInfo instance with a raw dictionary.
3131
///
32-
init(remote: [AnyHashable: Any]) {
32+
public init(remote: [AnyHashable: Any]) {
3333
name = remote["name"] as? String ?? ""
3434
tagline = remote["description"] as? String ?? ""
3535
url = remote["URL"] as? String ?? ""

0 commit comments

Comments
 (0)