Skip to content
This repository was archived by the owner on Feb 5, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def wordpress_authenticator_pods
##
pod 'Gridicons', '~> 0.15'
pod 'WordPressUI', '~> 1.4-beta.1'
pod 'WordPressKit', '~> 4.5.5'
pod 'WordPressKit', '~> 4.5.6-beta.1'
# pod 'WordPressKit', :git => 'https://github.com/wordpress-mobile/WordPressKit-iOS.git', :branch => 'issue/apple_2fa_auth'
pod 'WordPressShared', '~> 1.8'

Expand Down
8 changes: 4 additions & 4 deletions Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ PODS:
- Specta (1.0.7)
- SVProgressHUD (2.2.5)
- UIDeviceIdentifier (1.4.0)
- WordPressKit (4.5.5):
- WordPressKit (4.5.6-beta.1):
- Alamofire (~> 4.7.3)
- CocoaLumberjack (~> 3.4)
- NSObject-SafeExpectations (= 0.0.3)
Expand All @@ -71,7 +71,7 @@ DEPENDENCIES:
- OHHTTPStubs/Swift (= 8.0.0)
- Specta (= 1.0.7)
- SVProgressHUD (= 2.2.5)
- WordPressKit (~> 4.5.5)
- WordPressKit (~> 4.5.6-beta.1)
- WordPressShared (~> 1.8)
- WordPressUI (~> 1.4-beta.1)

Expand Down Expand Up @@ -117,11 +117,11 @@ SPEC CHECKSUMS:
Specta: 3e1bd89c3517421982dc4d1c992503e48bd5fe66
SVProgressHUD: 1428aafac632c1f86f62aa4243ec12008d7a51d6
UIDeviceIdentifier: 44f805037d21b94394821828f4fcaba34b38c2d0
WordPressKit: 8029cb93a89de79442254c346523da11c2706d7b
WordPressKit: eb6742df639843f5e7b2da9450da39d222b22ab8
WordPressShared: 09cf184caa614835f5811e8609227165201e6d3e
WordPressUI: 35b144885c8e5817ba6874b68accc200bda61ee1
wpxmlrpc: 6ba55c773cfa27083ae4a2173e69b19f46da98e2

PODFILE CHECKSUM: e4f5f036a95bf5e1df937bfa7d2d24b4ee5bbb18
PODFILE CHECKSUM: 0efdfa2e4fbdc215152337ee314105a404d69957

COCOAPODS: 1.8.4
4 changes: 2 additions & 2 deletions WordPressAuthenticator.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "WordPressAuthenticator"
s.version = "1.10.5"
s.version = "1.10.6"
s.summary = "WordPressAuthenticator implements an easy and elegant way to authenticate your WordPress Apps."

s.description = <<-DESC
Expand Down Expand Up @@ -39,6 +39,6 @@ Pod::Spec.new do |s|
s.dependency 'Gridicons', '~> 0.15'
s.dependency 'GoogleSignIn', '~> 4.4'
s.dependency 'WordPressUI', '~> 1.4-beta.1'
s.dependency 'WordPressKit', '~> 4.5.5'
s.dependency 'WordPressKit', '~> 4.5.6-beta.1'
s.dependency 'WordPressShared', '~> 1.8'
end
4 changes: 4 additions & 0 deletions WordPressAuthenticator.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
020BE74A23B0BD2E007FE54C /* WordPressAuthenticatorDisplayImages.swift in Sources */ = {isa = PBXBuildFile; fileRef = 020BE74923B0BD2E007FE54C /* WordPressAuthenticatorDisplayImages.swift */; };
1A21EE9822832BC300C940C6 /* WordPressComOAuthClientFacade+Swift.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A21EE9722832BC200C940C6 /* WordPressComOAuthClientFacade+Swift.swift */; };
1A4095182271AEFC009AA86D /* WPAuthenticator-Swift.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A4095152271AEFC009AA86D /* WPAuthenticator-Swift.h */; settings = {ATTRIBUTES = (Private, ); }; };
7A7A9B9CD2D81959F9AB9AF6 /* Pods_WordPressAuthenticator.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C736FF243DE333FCAB1C2614 /* Pods_WordPressAuthenticator.framework */; };
Expand Down Expand Up @@ -142,6 +143,7 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
020BE74923B0BD2E007FE54C /* WordPressAuthenticatorDisplayImages.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WordPressAuthenticatorDisplayImages.swift; sourceTree = "<group>"; };
1A21EE9722832BC200C940C6 /* WordPressComOAuthClientFacade+Swift.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "WordPressComOAuthClientFacade+Swift.swift"; sourceTree = "<group>"; };
1A4095152271AEFC009AA86D /* WPAuthenticator-Swift.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "WPAuthenticator-Swift.h"; sourceTree = "<group>"; };
276354F054C34AD36CA32AB6 /* Pods-WordPressAuthenticator.release-alpha.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WordPressAuthenticator.release-alpha.xcconfig"; path = "Pods/Target Support Files/Pods-WordPressAuthenticator/Pods-WordPressAuthenticator.release-alpha.xcconfig"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -433,6 +435,7 @@
B56090F6208A533200399AE4 /* WordPressSupportSourceTag.swift */,
CE1B18CF20EEC41600BECC3F /* WordPressAuthenticatorConfiguration.swift */,
CE1B18D120EEC44400BECC3F /* WordPressAuthenticatorStyles.swift */,
020BE74923B0BD2E007FE54C /* WordPressAuthenticatorDisplayImages.swift */,
CE16177421B6D82200B82A47 /* WordPressAuthenticatorDisplayStrings.swift */,
);
path = Authenticator;
Expand Down Expand Up @@ -879,6 +882,7 @@
B5609139208A563800399AE4 /* LoginEmailViewController.swift in Sources */,
98C9195B2308E3DA00A90E12 /* AppleAuthenticator.swift in Sources */,
B56090F9208A533200399AE4 /* WordPressAuthenticator+Events.swift in Sources */,
020BE74A23B0BD2E007FE54C /* WordPressAuthenticatorDisplayImages.swift in Sources */,
B560913A208A563800399AE4 /* LoginLinkRequestViewController.swift in Sources */,
B560910C208A54F800399AE4 /* WordPressComOAuthClientFacade.m in Sources */,
B55272C320B2FE4100E18BC5 /* WPAuthenticatorLoggingPrivate.m in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ import AuthenticationServices
///
public let style: WordPressAuthenticatorStyle

/// Authenticator's Display Images.
///
public let displayImages: WordPressAuthenticatorDisplayImages

/// Authenticator's Display Texts.
///
public let displayStrings: WordPressAuthenticatorDisplayStrings
Expand All @@ -65,22 +69,28 @@ import AuthenticationServices
///
private init(configuration: WordPressAuthenticatorConfiguration,
style: WordPressAuthenticatorStyle,
displayImages: WordPressAuthenticatorDisplayImages,
displayStrings: WordPressAuthenticatorDisplayStrings) {
self.configuration = configuration
self.style = style
self.displayImages = displayImages
self.displayStrings = displayStrings
}

/// Initializes the WordPressAuthenticator with the specified Configuration.
///
public static func initialize(configuration: WordPressAuthenticatorConfiguration,
style: WordPressAuthenticatorStyle,
displayImages: WordPressAuthenticatorDisplayImages = .defaultImages,
displayStrings: WordPressAuthenticatorDisplayStrings = .defaultStrings) {
guard privateInstance == nil else {
fatalError("WordPressAuthenticator is already initialized")
}

privateInstance = WordPressAuthenticator(configuration: configuration, style: style, displayStrings: displayStrings)
privateInstance = WordPressAuthenticator(configuration: configuration,
style: style,
displayImages: displayImages,
displayStrings: displayStrings)
}

// MARK: - Public Methods
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// MARK: - WordPress Authenticator Display Images
//
public struct WordPressAuthenticatorDisplayImages {
public let magicLink: UIImage
public let siteAddressModalPlaceholder: UIImage

/// Designated initializer.
///
public init(magicLink: UIImage, siteAddressModalPlaceholder: UIImage) {
self.magicLink = magicLink
self.siteAddressModalPlaceholder = siteAddressModalPlaceholder
}
}

public extension WordPressAuthenticatorDisplayImages {
static var defaultImages: WordPressAuthenticatorDisplayImages {
return WordPressAuthenticatorDisplayImages(
magicLink: .magicLinkImage,
siteAddressModalPlaceholder: .siteAddressModalPlaceholder
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ public extension WordPressAuthenticatorDisplayStrings {
static var defaultStrings: WordPressAuthenticatorDisplayStrings {
return WordPressAuthenticatorDisplayStrings(emailLoginInstructions: NSLocalizedString("Log in to your WordPress.com account with your email address.", comment: "Instruction text on the login's email address screen."),
jetpackLoginInstructions: NSLocalizedString("Log in to the WordPress.com account you used to connect Jetpack.", comment: "Instruction text on the login's email address screen."),
siteLoginInstructions: NSLocalizedString("Enter the address of your WordPress site you'd like to connect.", comment: "Instruction text on the login's site addresss screen."))
siteLoginInstructions: NSLocalizedString("Enter the address of the WordPress site you'd like to connect.", comment: "Instruction text on the login's site addresss screen."))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ extension FancyAlertViewController {
}
}

let image = UIImage.siteAddressModalPlaceholder
let image = WordPressAuthenticator.shared.displayImages.siteAddressModalPlaceholder

let config = FancyAlertViewController.Config(titleText: Strings.titleText,
bodyText: Strings.bodyText,
Expand Down
11 changes: 11 additions & 0 deletions WordPressAuthenticator/Extensions/UIImage+Assets.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ import Foundation
// MARK: - Named Assets
//
extension UIImage {
/// Returns the Link Image.
///
static var linkFieldImage: UIImage {
return UIImage(named: "icon-url-field", in: bundle, compatibleWith: nil)!
}

/// Returns the Default Magic Link Image.
///
static var magicLinkImage: UIImage {
return UIImage(named: "login-magic-link", in: bundle, compatibleWith: nil)!
}

/// Returns the Default Site Icon Placeholder Image.
///
Expand Down
3 changes: 3 additions & 0 deletions WordPressAuthenticator/Extensions/WPStyleGuide+Login.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ extension WPStyleGuide {
onePasswordButton.setImage(.onePasswordImage, for: .normal)
onePasswordButton.sizeToFit()

onePasswordButton.accessibilityLabel =
NSLocalizedString("Fill with password manager", comment: "The password manager button in login pages. The button opens a dialog showing which password manager to use (e.g. 1Password, LastPass). ")

textField.rightView = onePasswordButton
textField.rightViewMode = .always

Expand Down
11 changes: 11 additions & 0 deletions WordPressAuthenticator/NUX/NUXLinkMailViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import WordPressShared
/// app to look for the emailed authentication link.
///
class NUXLinkMailViewController: LoginViewController {
@IBOutlet private weak var imageView: UIImageView!
@IBOutlet var label: UILabel?
@IBOutlet var openMailButton: NUXButton?
@IBOutlet var usePasswordButton: UIButton?
Expand All @@ -27,6 +28,8 @@ class NUXLinkMailViewController: LoginViewController {
override func viewDidLoad() {
super.viewDidLoad()

imageView.image = WordPressAuthenticator.shared.displayImages.magicLink

let email = loginFields.username
if !email.isValidEmail() {
assert(email.isValidEmail(), "The value of loginFields.username was not a valid email address.")
Expand All @@ -35,6 +38,7 @@ class NUXLinkMailViewController: LoginViewController {
emailMagicLinkSource = loginFields.meta.emailMagicLinkSource
assert(emailMagicLinkSource != nil, "Must have an email link source.")

styleUsePasswordButton()
localizeControls()
}

Expand All @@ -44,6 +48,13 @@ class NUXLinkMailViewController: LoginViewController {

// MARK: - Configuration

private func styleUsePasswordButton() {
guard let usePasswordButton = usePasswordButton else {
return
}
WPStyleGuide.configureTextButton(usePasswordButton)
}

/// Assigns localized strings to various UIControl defined in the storyboard.
///
@objc func localizeControls() {
Expand Down
16 changes: 16 additions & 0 deletions WordPressAuthenticator/NUX/WPWalkthroughTextField.m
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ - (void)configureSecureTextEntryToggle {
[self.secureTextEntryToggle addTarget:self action:@selector(secureTextEntryToggleAction:) forControlEvents:UIControlEventTouchUpInside];

[self updateSecureTextEntryToggleImage];
[self updateSecureTextEntryForAccessibility];

self.rightView = self.secureTextEntryToggle;
self.rightViewMode = UITextFieldViewModeAlways;
}
Expand Down Expand Up @@ -253,6 +255,7 @@ - (void)setSecureTextEntry:(BOOL)secureTextEntry

[super setSecureTextEntry:secureTextEntry];
[self updateSecureTextEntryToggleImage];
[self updateSecureTextEntryForAccessibility];
}

- (void)secureTextEntryToggleAction:(id)sender
Expand All @@ -272,4 +275,17 @@ - (void)updateSecureTextEntryToggleImage
[self.secureTextEntryToggle sizeToFit];
}

- (void)updateSecureTextEntryForAccessibility
{
self.secureTextEntryToggle.accessibilityLabel = NSLocalizedString(@"Show password", @"Accessibility label for the “Show password“ button in the login page's password field.");

NSString *accessibilityValue;
if (self.isSecureTextEntry) {
accessibilityValue = NSLocalizedString(@"Hidden", "Accessibility value if login page's password field is hiding the password (i.e. with asterisks).");
} else {
accessibilityValue = NSLocalizedString(@"Shown", "Accessibility value if login page's password field is displaying the password.");
}
self.secureTextEntryToggle.accessibilityValue = accessibilityValue;
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,9 @@
"info" : {
"version" : 1,
"author" : "xcode"
},
"properties" : {
"template-rendering-intent" : "template",
"preserves-vector-representation" : true
}
}
1 change: 1 addition & 0 deletions WordPressAuthenticator/Signin/EmailMagicLink.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@
</variation>
</view>
<connections>
<outlet property="imageView" destination="upR-OL-iQF" id="yFk-fN-VV9"/>
<outlet property="label" destination="pkM-xx-821" id="nOS-5r-86h"/>
<outlet property="openMailButton" destination="0Iy-9H-ykD" id="Xwh-40-c65"/>
<outlet property="usePasswordButton" destination="b0O-LO-6ax" id="mqE-R7-rGj"/>
Expand Down
27 changes: 25 additions & 2 deletions WordPressAuthenticator/Signin/LoginSelfHostedViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class LoginSelfHostedViewController: LoginViewController, NUXKeyboardResponder {
localizeControls()
setupOnePasswordButtonIfNeeded()
displayLoginMessage("")
configureForAcessibility()
}


Expand Down Expand Up @@ -90,6 +91,26 @@ class LoginSelfHostedViewController: LoginViewController, NUXKeyboardResponder {
}


/// Sets up necessary accessibility labels and attributes for the all the UI elements in self.
///
private func configureForAcessibility() {
usernameField.accessibilityLabel =
NSLocalizedString("Username", comment: "Accessibility label for the username text field in the self-hosted login page.")
passwordField.accessibilityLabel =
NSLocalizedString("Password", comment: "Accessibility label for the password text field in the self-hosted login page.")

if UIAccessibility.isVoiceOverRunning {
// Remove the placeholder if VoiceOver is running. VoiceOver speaks the label and the
// placeholder together. In this case, both labels and placeholders are the same so it's
// like VoiceOver is reading the same thing twice.
usernameField.placeholder = nil
passwordField.placeholder = nil
}

forgotPasswordButton.accessibilityTraits = .link
}


/// Sets up a 1Password button if 1Password is available.
///
@objc func setupOnePasswordButtonIfNeeded() {
Expand Down Expand Up @@ -187,7 +208,7 @@ class LoginSelfHostedViewController: LoginViewController, NUXKeyboardResponder {
siteHeaderView.subtitleIsHidden = true

siteHeaderView.blavatarBorderIsHidden = true
siteHeaderView.blavatarImage = UIImage.linkFieldImage.imageWithTintColor(WordPressAuthenticator.shared.style.placeholderColor)
siteHeaderView.blavatarImage = .linkFieldImage
}


Expand Down Expand Up @@ -294,7 +315,9 @@ extension LoginSelfHostedViewController {
configureViewLoading(false)
let err = error as NSError
if err.code == 403 {
displayError(message: NSLocalizedString("It looks like this username/password isn't associated with this site.", comment: "An error message shown during log in when the username or password is incorrect."))
let message = NSLocalizedString("It looks like this username/password isn't associated with this site.",
comment: "An error message shown during log in when the username or password is incorrect.")
displayError(message: message, moveVoiceOverFocus: true)
} else {
displayError(error as NSError, sourceTag: sourceTag)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class LoginSiteAddressViewController: LoginViewController, NUXKeyboardResponder
override func viewDidLoad() {
super.viewDidLoad()
localizeControls()
configureForAccessibility()
}


Expand Down Expand Up @@ -90,6 +91,12 @@ class LoginSiteAddressViewController: LoginViewController, NUXKeyboardResponder
siteAddressHelpButton.titleLabel?.numberOfLines = 0
}

/// Sets up necessary accessibility labels and attributes for the all the UI elements in self.
///
private func configureForAccessibility() {
siteURLField.accessibilityLabel =
NSLocalizedString("Site address", comment: "Accessibility label of the site address field shown when adding a self-hosted site.")
}

/// Configures the content of the text fields based on what is saved in `loginFields`.
///
Expand Down Expand Up @@ -178,15 +185,15 @@ class LoginSiteAddressViewController: LoginViewController, NUXKeyboardResponder
let err = self.originalErrorOrError(error: error as NSError)

if let xmlrpcValidatorError = err as? WordPressOrgXMLRPCValidatorError {
self.displayError(message: xmlrpcValidatorError.localizedDescription)
self.displayError(message: xmlrpcValidatorError.localizedDescription, moveVoiceOverFocus: true)

} else if (err.domain == NSURLErrorDomain && err.code == NSURLErrorCannotFindHost) ||
(err.domain == NSURLErrorDomain && err.code == NSURLErrorNetworkConnectionLost) {
// NSURLErrorNetworkConnectionLost can be returned when an invalid URL is entered.
let msg = NSLocalizedString(
"The site at this address is not a WordPress site. For us to connect to it, the site must use WordPress.",
comment: "Error message shown a URL does not point to an existing site.")
self.displayError(message: msg)
self.displayError(message: msg, moveVoiceOverFocus: true)

} else {
self.displayError(error as NSError, sourceTag: self.sourceTag)
Expand Down
Loading