Skip to content

Commit 8a17f96

Browse files
committed
Restore button to show web login flow for invalid credentials
1 parent f1db5c3 commit 8a17f96

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

WooCommerce/Classes/Authentication/AuthenticationManager.swift

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ extension AuthenticationManager: WordPressAuthenticatorDelegate {
372372
}
373373
}()
374374

375-
// Only show the tutorial if the error can be solved by the app password flow.
375+
// Show the tutorial immediately if it's obvious that the error can be solved by the app password flow.
376376
if isAppPasswordAuthError {
377377
presentAppPasswordTutorial(error: error, for: siteURL, in: viewController)
378378
} else {
@@ -798,10 +798,20 @@ private extension AuthenticationManager {
798798
/// Presents login error alert before redirecting user to the site login using a web view.
799799
///
800800
private func presentAppPasswordAlert(error: Error, for siteURL: String, in viewController: UIViewController) {
801-
801+
let shouldEnableWebFlow: Bool = {
802+
if let siteCredentialError = error as? SiteCredentialLoginError,
803+
case .invalidCredentials = siteCredentialError {
804+
return true
805+
}
806+
return false
807+
}()
808+
let defaultAction = shouldEnableWebFlow ? { [weak self] in
809+
guard let self else { return }
810+
presentApplicationPasswordWebView(for: siteURL, in: viewController)
811+
} : nil
802812
let alertController = FancyAlertViewController.makeSiteCredentialLoginErrorAlert(
803813
message: (error as NSError).localizedDescription,
804-
defaultAction: nil
814+
defaultAction: defaultAction
805815
)
806816

807817
viewController.present(alertController, animated: true)

0 commit comments

Comments
 (0)