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

Commit 6100651

Browse files
committed
Merge branch 'develop'
2 parents 5711bfa + 7922c39 commit 6100651

File tree

10 files changed

+90
-9
lines changed

10 files changed

+90
-9
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.8.0-beta.3"
3+
s.version = "1.8.0-beta.5"
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: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
7A7A9B9CD2D81959F9AB9AF6 /* Pods_WordPressAuthenticator.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C736FF243DE333FCAB1C2614 /* Pods_WordPressAuthenticator.framework */; };
1313
982C8E7923021C20003F1BA0 /* LoginPrologueLoginMethodViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 982C8E7823021C20003F1BA0 /* LoginPrologueLoginMethodViewController.swift */; };
1414
98AA5A5720AA1A7000A5958A /* WPHelpIndicatorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98AA5A5620AA1A7000A5958A /* WPHelpIndicatorView.swift */; };
15+
98C9195B2308E3DA00A90E12 /* AppleAuthenticator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98C9195A2308E3D900A90E12 /* AppleAuthenticator.swift */; };
1516
B501C045208FC68700D1E58F /* LoginFieldsValidationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B501C03C208FC52400D1E58F /* LoginFieldsValidationTests.swift */; };
1617
B501C046208FC6A700D1E58F /* WordPressAuthenticatorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B501C03E208FC52500D1E58F /* WordPressAuthenticatorTests.swift */; };
1718
B501C048208FC79C00D1E58F /* LoginFacadeTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B501C040208FC52500D1E58F /* LoginFacadeTests.m */; };
@@ -149,8 +150,8 @@
149150
5A441EC80D2B8D2209C2E228 /* Pods_WordPressAuthenticatorTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_WordPressAuthenticatorTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
150151
8F7217C3F7A6285D9C6CF786 /* Pods-WordPressAuthenticator.release-internal.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WordPressAuthenticator.release-internal.xcconfig"; path = "Pods/Target Support Files/Pods-WordPressAuthenticator/Pods-WordPressAuthenticator.release-internal.xcconfig"; sourceTree = "<group>"; };
151152
982C8E7823021C20003F1BA0 /* LoginPrologueLoginMethodViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LoginPrologueLoginMethodViewController.swift; sourceTree = "<group>"; };
152-
982C8E7E2302355B003F1BA0 /* LoginPrologueLoginMethodViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = LoginPrologueLoginMethodViewController.swift; path = WordPressAuthenticator/Signin/LoginPrologueLoginMethodViewController.swift; sourceTree = "<group>"; };
153153
98AA5A5620AA1A7000A5958A /* WPHelpIndicatorView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WPHelpIndicatorView.swift; sourceTree = "<group>"; };
154+
98C9195A2308E3D900A90E12 /* AppleAuthenticator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppleAuthenticator.swift; sourceTree = "<group>"; };
154155
AE612958059F9E80B54138B3 /* Pods-WordPressAuthenticatorTests.release-internal.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WordPressAuthenticatorTests.release-internal.xcconfig"; path = "Pods/Target Support Files/Pods-WordPressAuthenticatorTests/Pods-WordPressAuthenticatorTests.release-internal.xcconfig"; sourceTree = "<group>"; };
155156
B0D7D40BC1DE2D367761AD86 /* Pods-WordPressAuthenticatorTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WordPressAuthenticatorTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-WordPressAuthenticatorTests/Pods-WordPressAuthenticatorTests.debug.xcconfig"; sourceTree = "<group>"; };
156157
B501C03C208FC52400D1E58F /* LoginFieldsValidationTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LoginFieldsValidationTests.swift; sourceTree = "<group>"; };
@@ -352,9 +353,9 @@
352353
B5609128208A563600399AE4 /* LoginEmailViewController.swift */,
353354
B5609129208A563600399AE4 /* LoginLinkRequestViewController.swift */,
354355
B5609131208A563700399AE4 /* LoginNavigationController.swift */,
355-
982C8E7823021C20003F1BA0 /* LoginPrologueLoginMethodViewController.swift */,
356356
B560912C208A563700399AE4 /* LoginProloguePageViewController.swift */,
357357
B560912B208A563600399AE4 /* LoginProloguePromoViewController.swift */,
358+
982C8E7823021C20003F1BA0 /* LoginPrologueLoginMethodViewController.swift */,
358359
B5609133208A563700399AE4 /* LoginPrologueSignupMethodViewController.swift */,
359360
B5609130208A563700399AE4 /* LoginPrologueViewController.swift */,
360361
B560912A208A563600399AE4 /* LoginSelfHostedViewController.swift */,
@@ -365,6 +366,7 @@
365366
B5609134208A563700399AE4 /* LoginViewController.swift */,
366367
B5609124208A563600399AE4 /* LoginWPComViewController.swift */,
367368
B560912D208A563700399AE4 /* SigninEditingState.swift */,
369+
98C9195A2308E3D900A90E12 /* AppleAuthenticator.swift */,
368370
);
369371
path = Signin;
370372
sourceTree = "<group>";
@@ -491,7 +493,6 @@
491493
B5ED78EA207E976500A8FD8C = {
492494
isa = PBXGroup;
493495
children = (
494-
982C8E7E2302355B003F1BA0 /* LoginPrologueLoginMethodViewController.swift */,
495496
FF629D9522393500004C4106 /* WordPressAuthenticator.podspec */,
496497
B5ED78F6207E976500A8FD8C /* WordPressAuthenticator */,
497498
B5ED7901207E976500A8FD8C /* WordPressAuthenticatorTests */,
@@ -880,6 +881,7 @@
880881
CE30A2AD2257CECC00DF3CDA /* AuthenticatorCredentials.swift in Sources */,
881882
B5609145208A563800399AE4 /* LoginViewController.swift in Sources */,
882883
B5609139208A563800399AE4 /* LoginEmailViewController.swift in Sources */,
884+
98C9195B2308E3DA00A90E12 /* AppleAuthenticator.swift in Sources */,
883885
B56090F9208A533200399AE4 /* WordPressAuthenticator+Events.swift in Sources */,
884886
B560913A208A563800399AE4 /* LoginLinkRequestViewController.swift in Sources */,
885887
B560910C208A54F800399AE4 /* WordPressComOAuthClientFacade.m in Sources */,

WordPressAuthenticator/Authenticator/WordPressAuthenticator.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ import WordPressUI
139139
childController.loginFields.restrictToWPCom = restrictToWPCom
140140
childController.showCancel = showCancel
141141
}
142+
controller.modalPresentationStyle = .fullScreen
142143
presenter.present(controller, animated: animated, completion: nil)
143144
}
144145
}
@@ -165,6 +166,7 @@ import WordPressUI
165166
}
166167

167168
let navController = LoginNavigationController(rootViewController: controller)
169+
navController.modalPresentationStyle = .fullScreen
168170
presenter.present(navController, animated: true, completion: nil)
169171
}
170172

@@ -176,7 +178,7 @@ import WordPressUI
176178

177179
let controller = signinForWPOrg()
178180
let navController = LoginNavigationController(rootViewController: controller)
179-
181+
navController.modalPresentationStyle = .fullScreen
180182
presenter.present(navController, animated: true, completion: nil)
181183
}
182184

@@ -274,6 +276,7 @@ import WordPressUI
274276
}
275277

276278
let navController = LoginNavigationController(rootViewController: controller)
279+
navController.modalPresentationStyle = .fullScreen
277280

278281
// The way the magic link flow works some view controller might
279282
// still be presented when the app is resumed by tapping on the auth link.

WordPressAuthenticator/Authenticator/WordPressAuthenticatorStyles.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,13 @@ public struct WordPressAuthenticatorStyle {
7171
///
7272
public let prologueTitleColor: UIColor
7373

74+
/// Style: status bar style
75+
///
76+
public let statusBarStyle: UIStatusBarStyle
77+
7478
/// Designated initializer
7579
///
76-
public init(primaryNormalBackgroundColor: UIColor, primaryNormalBorderColor: UIColor, primaryHighlightBackgroundColor: UIColor, primaryHighlightBorderColor: UIColor, secondaryNormalBackgroundColor: UIColor, secondaryNormalBorderColor: UIColor, secondaryHighlightBackgroundColor: UIColor, secondaryHighlightBorderColor: UIColor, disabledBackgroundColor: UIColor, disabledBorderColor: UIColor, primaryTitleColor: UIColor, secondaryTitleColor: UIColor, disabledTitleColor: UIColor, textButtonColor: UIColor, textButtonHighlightColor: UIColor, instructionColor: UIColor, subheadlineColor: UIColor, placeholderColor: UIColor, viewControllerBackgroundColor: UIColor, navBarImage: UIImage, navBarBadgeColor: UIColor, prologueBackgroundColor: UIColor = WPStyleGuide.wordPressBlue(), prologueTitleColor: UIColor = .white) {
80+
public init(primaryNormalBackgroundColor: UIColor, primaryNormalBorderColor: UIColor, primaryHighlightBackgroundColor: UIColor, primaryHighlightBorderColor: UIColor, secondaryNormalBackgroundColor: UIColor, secondaryNormalBorderColor: UIColor, secondaryHighlightBackgroundColor: UIColor, secondaryHighlightBorderColor: UIColor, disabledBackgroundColor: UIColor, disabledBorderColor: UIColor, primaryTitleColor: UIColor, secondaryTitleColor: UIColor, disabledTitleColor: UIColor, textButtonColor: UIColor, textButtonHighlightColor: UIColor, instructionColor: UIColor, subheadlineColor: UIColor, placeholderColor: UIColor, viewControllerBackgroundColor: UIColor, navBarImage: UIImage, navBarBadgeColor: UIColor, prologueBackgroundColor: UIColor = WPStyleGuide.wordPressBlue(), prologueTitleColor: UIColor = .white, statusBarStyle: UIStatusBarStyle = .lightContent) {
7781
self.primaryNormalBackgroundColor = primaryNormalBackgroundColor
7882
self.primaryNormalBorderColor = primaryNormalBorderColor
7983
self.primaryHighlightBackgroundColor = primaryHighlightBackgroundColor
@@ -97,5 +101,6 @@ public struct WordPressAuthenticatorStyle {
97101
self.navBarBadgeColor = navBarBadgeColor
98102
self.prologueBackgroundColor = prologueBackgroundColor
99103
self.prologueTitleColor = prologueTitleColor
104+
self.statusBarStyle = statusBarStyle
100105
}
101106
}

WordPressAuthenticator/Extensions/WPStyleGuide+Login.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ extension WPStyleGuide {
149149

150150
let attrStrNormal = baseString.underlined(color: style.subheadlineColor, underlineColor: style.textButtonColor)
151151
let attrStrHighlight = baseString.underlined(color: style.subheadlineColor, underlineColor: style.textButtonHighlightColor)
152-
let font = WPStyleGuide.mediumWeightFont(forStyle: .caption2)
152+
let font = WPStyleGuide.mediumWeightFont(forStyle: .subheadline)
153153

154154
button = textButton(normal: attrStrNormal, highlighted: attrStrHighlight, font: font, alignment: alignment)
155155
} else {
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import Foundation
2+
import AuthenticationServices
3+
4+
class AppleAuthenticator: NSObject {
5+
6+
// MARK: - Properties
7+
8+
static var sharedInstance: AppleAuthenticator = AppleAuthenticator()
9+
private override init() {}
10+
private var showFromViewController: UIViewController?
11+
12+
// MARK: - Start Authentication
13+
14+
func showFrom(viewController: UIViewController) {
15+
showFromViewController = viewController
16+
requestAuthorization()
17+
}
18+
19+
}
20+
21+
private extension AppleAuthenticator {
22+
23+
func requestAuthorization() {
24+
#if XCODE11
25+
if #available(iOS 13.0, *) {
26+
let provider = ASAuthorizationAppleIDProvider()
27+
let request = provider.createRequest()
28+
request.requestedScopes = [.fullName, .email]
29+
30+
let controller = ASAuthorizationController(authorizationRequests: [request])
31+
controller.delegate = self
32+
33+
controller.presentationContextProvider = self
34+
controller.performRequests()
35+
36+
}
37+
#endif
38+
}
39+
40+
}
41+
42+
#if XCODE11
43+
@available(iOS 13.0, *)
44+
extension AppleAuthenticator: ASAuthorizationControllerDelegate {
45+
46+
func authorizationController(controller: ASAuthorizationController, didCompleteWithAuthorization authorization: ASAuthorization) {
47+
switch authorization.credential {
48+
case let credentials as ASAuthorizationAppleIDCredential:
49+
NSLog("Apple Authenticator credentials: \(String(describing: credentials.email)), \(String(describing: credentials.fullName))")
50+
default:
51+
break
52+
}
53+
}
54+
55+
func authorizationController(controller: ASAuthorizationController, didCompleteWithError error: Error) {
56+
NSLog("Apple Authenticator didCompleteWithError: \(error)")
57+
}
58+
59+
}
60+
61+
@available(iOS 13.0, *)
62+
extension AppleAuthenticator: ASAuthorizationControllerPresentationContextProviding {
63+
func presentationAnchor(for controller: ASAuthorizationController) -> ASPresentationAnchor {
64+
return showFromViewController?.view.window ?? UIWindow()
65+
}
66+
}
67+
#endif

WordPressAuthenticator/Signin/LoginEmailViewController.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,7 @@ open class LoginEmailViewController: LoginViewController, NUXKeyboardResponder {
424424
let socialErrorNav = LoginNavigationController(rootViewController: socialErrorVC)
425425
socialErrorVC.delegate = self
426426
socialErrorVC.loginFields = loginFields
427+
socialErrorVC.modalPresentationStyle = .fullScreen
427428
present(socialErrorNav, animated: true) {}
428429
} else {
429430
errorToPresent = error

WordPressAuthenticator/Signin/LoginNavigationController.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,7 @@ import WordPressUI
44

55

66
public class LoginNavigationController: RotationAwareNavigationViewController {
7+
public override var preferredStatusBarStyle: UIStatusBarStyle {
8+
return WordPressAuthenticator.shared.style.statusBarStyle
9+
}
710
}

WordPressAuthenticator/Signin/LoginPrologueViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ class LoginPrologueViewController: LoginViewController {
115115
}
116116

117117
private func appleTapped() {
118-
print("Login Prologue: Apple tapped.")
118+
AppleAuthenticator.sharedInstance.showFrom(viewController: self)
119119
}
120120

121121
}

WordPressAuthenticator/Signin/LoginSiteAddressViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ class LoginSiteAddressViewController: LoginViewController, NUXKeyboardResponder
286286
}
287287

288288
private func appleTapped() {
289-
print("Login Site Address: Apple tapped.")
289+
AppleAuthenticator.sharedInstance.showFrom(viewController: self)
290290
}
291291

292292
/// Whether the form can be submitted.

0 commit comments

Comments
 (0)