Skip to content

Commit 4460629

Browse files
committed
Show specific alert for inaccessible login url
1 parent f2354d4 commit 4460629

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

WooCommerce/Classes/Authentication/PostSiteCredentialLoginChecker.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ private extension PostSiteCredentialLoginChecker {
5252
let errorUI = applicationPasswordDisabledUI(for: siteURL)
5353
navigationController.show(errorUI, sender: nil)
5454
}
55+
} catch ApplicationPasswordUseCaseError.unauthorizedRequest {
56+
await MainActor.run {
57+
self.showAlert(message: Localization.invalidLoginOrAdminURL, in: navigationController)
58+
}
5559
} catch {
5660
// show generic error
5761
await MainActor.run {
@@ -150,6 +154,13 @@ private extension PostSiteCredentialLoginChecker {
150154
onRetry()
151155
}
152156
alert.addAction(retryAction)
157+
} else {
158+
let supportAction = UIAlertAction(title: Localization.contactSupport, style: .default) { [weak self] _ in
159+
navigationController.popViewController(animated: true)
160+
self?.stores.deauthenticate()
161+
ServiceLocator.authenticationManager.presentSupport(from: navigationController, sourceTag: .loginSiteAddress)
162+
}
163+
alert.addAction(supportAction)
153164
}
154165
let restartAction = UIAlertAction(title: Localization.restartLoginButton, style: .cancel) { [weak self] _ in
155166
self?.stores.deauthenticate()
@@ -186,6 +197,11 @@ private extension PostSiteCredentialLoginChecker {
186197
"Error checking for the WooCommerce plugin.",
187198
comment: "Error message displayed when the WooCommerce plugin detail cannot be fetched after authentication"
188199
)
200+
static let invalidLoginOrAdminURL = NSLocalizedString(
201+
"Application password cannot be generated due to custom login or admin URL on your site.",
202+
comment: "Message to display when the constructed admin or login URL for the logged-in site is not accessible"
203+
)
204+
static let contactSupport = NSLocalizedString("Contact Support", comment: "Button to contact support for login")
189205
static let retryButton = NSLocalizedString("Try Again", comment: "Button to refetch application password for the current site")
190206
static let restartLoginButton = NSLocalizedString("Log In With Another Account", comment: "Button to restart the login flow.")
191207
}

0 commit comments

Comments
 (0)