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

Commit c296dbd

Browse files
authored
Merge pull request #656 from wordpress-mobile/wcios/password-errors
Pass a custom error for invalid WP.com password errors
2 parents 392d0fd + f3e746f commit c296dbd

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

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 = '2.1.0-beta.5'
5+
s.version = '2.1.0-beta.6'
66

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

WordPressAuthenticator/Unified Auth/View Related/Get Started/GetStartedViewController.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public enum SignInSource {
1313
/// The error during the sign in flow.
1414
public enum SignInError: Error {
1515
case invalidWPComEmail(source: SignInSource)
16+
case invalidWPComPassword(source: SignInSource)
1617

1718
init?(error: Error, source: SignInSource?) {
1819
let error = error as NSError
@@ -520,6 +521,7 @@ private extension GetStartedViewController {
520521
return
521522
}
522523

524+
vc.source = source
523525
vc.loginFields = loginFields
524526
vc.trackAsPasswordChallenge = false
525527

WordPressAuthenticator/Unified Auth/View Related/Password/PasswordViewController.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ class PasswordViewController: LoginViewController {
2121
///
2222
var trackAsPasswordChallenge = true
2323

24+
var source: SignInSource?
25+
2426
override var loginFields: LoginFields {
2527
didSet {
2628
loginFields.password = ""
@@ -121,6 +123,15 @@ class PasswordViewController: LoginViewController {
121123
let errorCode = nsError.code
122124
let errorDomain = nsError.domain
123125

126+
if let source = source, loginFields.meta.userIsDotCom {
127+
let passwordError = SignInError.invalidWPComPassword(source: source)
128+
if authenticationDelegate.shouldHandleError(passwordError) {
129+
authenticationDelegate.handleError(passwordError) { _ in
130+
// No custom navigation is expected in this case.
131+
}
132+
}
133+
}
134+
124135
if errorDomain == WordPressComOAuthClient.WordPressComOAuthErrorDomain,
125136
errorCode == WordPressComOAuthError.invalidRequest.rawValue {
126137

0 commit comments

Comments
 (0)