Skip to content

Commit 9a84317

Browse files
committed
- Change RequestAuthenticatorError enum to public in RequestAuthenticator.swift
- Import `RequestAuthenticatorError` in `ApplicationPasswordAuthorizationWebViewController.swift` - Update error navigation method name to `navigateToApplicationPasswordDisabledUI` in `ApplicationPasswordAuthorizationWebViewController.swift` - Modify error handling logic to differentiate between `applicationPasswordNotAvailable` and other errors in `ApplicationPasswordAuthorizationWebViewController.swift`
1 parent b8b44e1 commit 9a84317

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

Networking/Networking/ApplicationPassword/RequestAuthenticator.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Foundation
22

3-
enum RequestAuthenticatorError: Error {
3+
public enum RequestAuthenticatorError: Error {
44
case applicationPasswordUseCaseNotAvailable
55
case applicationPasswordNotAvailable
66
}

WooCommerce/Classes/Authentication/Application Password/ApplicationPasswordAuthorizationWebViewController.swift

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import UIKit
33
import WebKit
44
import protocol WooFoundation.Analytics
55
import struct Networking.ApplicationPassword
6+
import enum Networking.RequestAuthenticatorError
67

78
/// View with embedded web view to authorize application password for a site.
89
///
@@ -162,14 +163,19 @@ private extension ApplicationPasswordAuthorizationWebViewController {
162163
guard let url = try await viewModel.fetchAuthURL() else {
163164
DDLogError("⛔️ No authorization URL found for application passwords")
164165
analytics.track(.applicationPasswordAuthorizationURLNotAvailable)
165-
navigateToErrorUI()
166+
navigateToApplicationPasswordDisabledUI()
166167
return
167168
}
168169
loadAuthorizationPage(url: url)
169170
} catch {
170171
DDLogError("⛔️ Error fetching authorization URL for application passwords \(error)")
171172
analytics.track(.applicationPasswordAuthorizationURLFetchFailed, withError: error)
172-
navigateToErrorUI()
173+
if let authError = error as? Networking.RequestAuthenticatorError,
174+
authError == .applicationPasswordNotAvailable {
175+
navigateToApplicationPasswordDisabledUI()
176+
} else {
177+
showErrorAlert(message: Localization.authorizationRejected)
178+
}
173179
}
174180
activityIndicator.stopAnimating()
175181
}
@@ -184,7 +190,7 @@ private extension ApplicationPasswordAuthorizationWebViewController {
184190
}
185191
}
186192

187-
private func navigateToErrorUI() {
193+
private func navigateToApplicationPasswordDisabledUI() {
188194
let errorUI = applicationPasswordDisabledUI(for: viewModel.siteURL)
189195
// When the error view controller is popped, navigate to previous VC
190196
errorUI.navigationItem.leftBarButtonItem = UIBarButtonItem(

0 commit comments

Comments
 (0)