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

Commit 3efca7d

Browse files
authored
Merge pull request #784 from wordpress-mobile/wcios/app-login-link
Support WCiOS app login links with WPCOM and site credentials navigation
2 parents 2f0b6d0 + 76fb483 commit 3efca7d

File tree

4 files changed

+59
-3
lines changed

4 files changed

+59
-3
lines changed

Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ PODS:
99
- SVProgressHUD (2.2.5)
1010
- SwiftLint (0.49.1)
1111
- UIDeviceIdentifier (2.2.0)
12-
- WordPressAuthenticator (7.0.0):
12+
- WordPressAuthenticator (7.1.0):
1313
- Gridicons (~> 1.0)
1414
- "NSURL+IDN (= 0.4)"
1515
- SVProgressHUD (~> 2.2.5)
@@ -71,7 +71,7 @@ SPEC CHECKSUMS:
7171
SVProgressHUD: 1428aafac632c1f86f62aa4243ec12008d7a51d6
7272
SwiftLint: 32ee33ded0636d0905ef6911b2b67bbaeeedafa5
7373
UIDeviceIdentifier: f33af270ba9045ea18b31d9aab88e42a0082ea67
74-
WordPressAuthenticator: 6ae29636e22143b6237a841708713b308503d10c
74+
WordPressAuthenticator: f73ba530531bb14eedd2f2b69c9b2d387004026c
7575
WordPressKit: 8e1c5a64645a59493a7316f38468ac036de9c79b
7676
WordPressShared: 0aa459e5257a77184db87805a998f447443c9706
7777
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 = '7.0.0'
5+
s.version = '7.1.0'
66

77
s.summary = 'WordPressAuthenticator implements an easy and elegant way to authenticate your WordPress Apps.'
88
s.description = <<-DESC
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import Foundation
2+
3+
/// Navigates to the wp-admin site credentials flow.
4+
///
5+
public struct NavigateToEnterSiteCredentials: NavigationCommand {
6+
private let loginFields: LoginFields
7+
8+
public init(loginFields: LoginFields) {
9+
self.loginFields = loginFields
10+
}
11+
public func execute(from: UIViewController?) {
12+
let navigationController = (from as? UINavigationController) ?? from?.navigationController
13+
presentSiteCredentialsView(navigationController: navigationController,
14+
loginFields: loginFields)
15+
}
16+
}
17+
18+
private extension NavigateToEnterSiteCredentials {
19+
func presentSiteCredentialsView(navigationController: UINavigationController?, loginFields: LoginFields) {
20+
guard let controller = SiteCredentialsViewController.instantiate(from: .siteAddress) else {
21+
WPAuthenticatorLogError("Failed to navigate to SiteCredentialsViewController")
22+
return
23+
}
24+
25+
controller.loginFields = loginFields
26+
navigationController?.pushViewController(controller, animated: true)
27+
}
28+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import Foundation
2+
3+
/// Navigates to the WPCOM password flow.
4+
///
5+
public struct NavigateToEnterWPCOMPassword: NavigationCommand {
6+
private let loginFields: LoginFields
7+
8+
public init(loginFields: LoginFields) {
9+
self.loginFields = loginFields
10+
}
11+
public func execute(from: UIViewController?) {
12+
let navigationController = (from as? UINavigationController) ?? from?.navigationController
13+
presentPasswordView(navigationController: navigationController,
14+
loginFields: loginFields)
15+
}
16+
}
17+
18+
private extension NavigateToEnterWPCOMPassword {
19+
func presentPasswordView(navigationController: UINavigationController?, loginFields: LoginFields) {
20+
guard let controller = PasswordViewController.instantiate(from: .password) else {
21+
WPAuthenticatorLogError("Failed to navigate to PasswordViewController from GetStartedViewController")
22+
return
23+
}
24+
25+
controller.loginFields = loginFields
26+
navigationController?.pushViewController(controller, animated: true)
27+
}
28+
}

0 commit comments

Comments
 (0)