From 55504d1c68de304598b6a1e7587f6c7d8c8d2eb6 Mon Sep 17 00:00:00 2001 From: Jaclyn Chen Date: Fri, 5 Aug 2022 08:36:13 +0800 Subject: [PATCH 1/3] Allow delegate to handle invalid WPCom password error. --- .../Get Started/GetStartedViewController.swift | 2 ++ .../Password/PasswordViewController.swift | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/WordPressAuthenticator/Unified Auth/View Related/Get Started/GetStartedViewController.swift b/WordPressAuthenticator/Unified Auth/View Related/Get Started/GetStartedViewController.swift index b988a30de..48f7e8390 100644 --- a/WordPressAuthenticator/Unified Auth/View Related/Get Started/GetStartedViewController.swift +++ b/WordPressAuthenticator/Unified Auth/View Related/Get Started/GetStartedViewController.swift @@ -13,6 +13,7 @@ public enum SignInSource { /// The error during the sign in flow. public enum SignInError: Error { case invalidWPComEmail(source: SignInSource) + case invalidWPComPassword(source: SignInSource) init?(error: Error, source: SignInSource?) { let error = error as NSError @@ -520,6 +521,7 @@ private extension GetStartedViewController { return } + vc.source = source vc.loginFields = loginFields vc.trackAsPasswordChallenge = false diff --git a/WordPressAuthenticator/Unified Auth/View Related/Password/PasswordViewController.swift b/WordPressAuthenticator/Unified Auth/View Related/Password/PasswordViewController.swift index 961564d15..0209293b5 100644 --- a/WordPressAuthenticator/Unified Auth/View Related/Password/PasswordViewController.swift +++ b/WordPressAuthenticator/Unified Auth/View Related/Password/PasswordViewController.swift @@ -21,6 +21,8 @@ class PasswordViewController: LoginViewController { /// var trackAsPasswordChallenge = true + var source: SignInSource? + override var loginFields: LoginFields { didSet { loginFields.password = "" @@ -121,6 +123,15 @@ class PasswordViewController: LoginViewController { let errorCode = nsError.code let errorDomain = nsError.domain + if let source = source, loginFields.meta.userIsDotCom { + let passwordError = SignInError.invalidWPComPassword(source: source) + if authenticationDelegate.shouldHandleError(passwordError) { + authenticationDelegate.handleError(passwordError) { [weak self] _ in + // No custom navigation is expected in this case. + } + } + } + if errorDomain == WordPressComOAuthClient.WordPressComOAuthErrorDomain, errorCode == WordPressComOAuthError.invalidRequest.rawValue { From e807aba8ee34ef07c36f2185a553087bb8f42b63 Mon Sep 17 00:00:00 2001 From: Jaclyn Chen Date: Fri, 5 Aug 2022 08:36:43 +0800 Subject: [PATCH 2/3] Bump pod version. --- WordPressAuthenticator.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPressAuthenticator.podspec b/WordPressAuthenticator.podspec index 85088a1c9..01b0d0cbe 100644 --- a/WordPressAuthenticator.podspec +++ b/WordPressAuthenticator.podspec @@ -2,7 +2,7 @@ Pod::Spec.new do |s| s.name = 'WordPressAuthenticator' - s.version = '2.1.0-beta.5' + s.version = '2.1.0-beta.6' s.summary = 'WordPressAuthenticator implements an easy and elegant way to authenticate your WordPress Apps.' s.description = <<-DESC From f3e746f386a94d79dd25adff1cb5d90f354ccad3 Mon Sep 17 00:00:00 2001 From: Jaclyn Chen Date: Fri, 5 Aug 2022 08:47:20 +0800 Subject: [PATCH 3/3] Remove unused self. --- .../View Related/Password/PasswordViewController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPressAuthenticator/Unified Auth/View Related/Password/PasswordViewController.swift b/WordPressAuthenticator/Unified Auth/View Related/Password/PasswordViewController.swift index 0209293b5..a573fb899 100644 --- a/WordPressAuthenticator/Unified Auth/View Related/Password/PasswordViewController.swift +++ b/WordPressAuthenticator/Unified Auth/View Related/Password/PasswordViewController.swift @@ -126,7 +126,7 @@ class PasswordViewController: LoginViewController { if let source = source, loginFields.meta.userIsDotCom { let passwordError = SignInError.invalidWPComPassword(source: source) if authenticationDelegate.shouldHandleError(passwordError) { - authenticationDelegate.handleError(passwordError) { [weak self] _ in + authenticationDelegate.handleError(passwordError) { _ in // No custom navigation is expected in this case. } }