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

Commit 55504d1

Browse files
committed
Allow delegate to handle invalid WPCom password error.
1 parent 392d0fd commit 55504d1

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

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) { [weak self] _ 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)