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

Conversation

@shiki
Copy link
Contributor

@shiki shiki commented Jun 3, 2021

Fixes woocommerce/woocommerce-ios#3962.

Findings

The WooCommerce app does not allow automatic sign-up emails. If the entered email address is not recognized, it displays this custom error message:

However, this regressed when #574 was merged. And eventually got “fixed” again when #590 was merged. Funny how life works. It wasn't a complete fix though because it doesn't show the custom UI. It only shows an alert:

Solution

I restored a part of the changes in #574 so that the WordPressAuthenticator.shared.delegate is now inquired if it would like to display a custom UI before calling displayError().

guard let authenticationDelegate = WordPressAuthenticator.shared.delegate,
authenticationDelegate.shouldHandleError(error) else {
self.displayError(error as NSError, sourceTag: self.sourceTag)
return
}
/// Hand over control to the host app.
authenticationDelegate.handleError(error) { customUI in
// Setting the rightBarButtonItems of the custom UI before pushing the view controller
// and resetting the navigationController's navigationItem after the push seems to be the
// only combination that gets the Help button to show up.
customUI.navigationItem.rightBarButtonItems = self.navigationItem.rightBarButtonItems
self.navigationController?.navigationItem.rightBarButtonItems = self.navigationItem.rightBarButtonItems
self.navigationController?.pushViewController(customUI, animated: true)
}

This is pretty much the same code as before, only in a different location. This is enough for the WooCommerce app to handle and display the UI. See woocommerce/woocommerce-ios#4365 for the WIP branch.

Testing

WordPress and Jetpack

Please test for regressions in WordPress and Jetpack.

  1. Use the draft branch in Fix Error Handling in Site Address Entry WordPress-iOS#16627.

  2. In WordPress, log in with an email that is not registered in WPCOM. WordPress should respond with “We've emailed you a signup link...”:

  3. In Jetpack, log in with an email that is not registered in WPCOM. Jetpack should respond with “User does not exist”.

WooCommerce (Optional)

If you have time, please test that WooCommerce will now display a custom UI.

  1. Use the draft branch: Do Not Send Sign-up Emails if the Email Address Is Unknown woocommerce/woocommerce-ios#4365.
  2. Log in with an email that is not registered in WPCOM. The app should respond with the custom UI saying “It looks like this email is not associated with...”

shiki added 2 commits June 3, 2021 11:21
This reverts some of the changes in 3b46ba8. That commit removed the ability for
the host app to override errors.

I'm applying it a bit differently here though. There was a condition added in
5cadb62 which automatically added an error dialog if the
`WordPressAuthenticator.shared.configuration.enableSignUp` is `false`. The
`sendEmail` is no longer called so I'm adding the override directly in `handleLoginError()`.
Copy link
Contributor

@ScoutHarris ScoutHarris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @shiki . Thanks for creating a test branch for WP/JP!

  • In WordPress, log in with an email that is not registered in WPCOM. WordPress should respond with “We've emailed you a signup link...” - ✅
  • In Jetpack, log in with an email that is not registered in WPCOM. Jetpack should respond with “User does not exist”. - ✅

:shipit: !

@shiki
Copy link
Contributor Author

shiki commented Jun 3, 2021

Thank you for the quick review, @ScoutHarris! 🙇

@shiki shiki merged commit 6a463a8 into develop Jun 3, 2021
@shiki shiki deleted the issue/wc-3962-allow-login-override branch June 3, 2021 22:38
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Automatic Sign-ups Should Be Disabled

3 participants