Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Login] Remove dependency on XMLRPC for the Account Mismatch flow #13308

Merged
merged 6 commits into from
Jan 17, 2025

Conversation

hichamboushaba
Copy link
Member

@hichamboushaba hichamboushaba commented Jan 14, 2025

Closes: #3974

Description

This PR updates the Account Mismatch flow to not depend on XMLRPC anymore, it uses now Cookies+Nonce authentication for fetching the email of the Jetpack User to continue with authentication or connection.

(We might want to unify this Jetpack setup logic with the other one in the JetpackActivation... screens, as it's almost the same, but for now this does the job)

Steps to reproduce

  1. Prepare a site that has two wp-admin users, one is connected to Jetpack (user A) and the other not (user B).
  2. Install this plugin to disable XMLRPC
  3. Logout from the app if needed.
  4. Open the app, then enter the site address.
  5. Enter a WordPress.com email that's not connected to the site.
  6. After connection, you'll land on the "Account Mismatch" screen.
  7. Tap on connect Jetpack.
  8. Enter the site credentials of user B.

(Following the above on trunk will fail, but won't crash the app, the crash of the linked issue is caused by some other XMLRPC issues, but given we don't use XMLRPC anymore, we fix the crash as well)

Testing information

  • Confirm the Jetpack connection works as expected even when XMLRPC is disabled.

The tests that have been performed

  • I tested the Jetpack connection as above.
  • I also tested the flow of entering the credentials on an already connected account, which should trigger WordPress.com authentication.

Images/gif

Screen_recording_20250114_175907.mp4
  • I have considered if this change warrants release notes and have added them to RELEASE-NOTES.txt if necessary. Use the "[Internal]" label for non-user-facing changes.

Reviewer (or Author, in the case of optional code reviews):

Please make sure these conditions are met before approving the PR, or request changes if the PR needs improvement:

  • The PR is small and has a clear, single focus, or a valid explanation is provided in the description. If needed, please request to split it into smaller PRs.
  • Ensure Adequate Unit Test Coverage: The changes are reasonably covered by unit tests or an explanation is provided in the PR description.
  • Manual Testing: The author listed all the tests they ran, including smoke tests when needed (e.g., for refactorings). The reviewer confirmed that the PR works as expected on big (tablet) and small (phone) in case of UI changes, and no regressions are added.

@hichamboushaba hichamboushaba added type: enhancement A request for an enhancement. feature: login Related to any part of the log in or sign in flow, or authentication. labels Jan 14, 2025
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Jan 14, 2025

📲 You can test the changes from this Pull Request in WooCommerce-Wear Android by scanning the QR code below to install the corresponding build.
App Name WooCommerce-Wear Android
Platform⌚️ Wear OS
FlavorJalapeno
Build TypeDebug
Commit1e6f712
Direct Downloadwoocommerce-wear-prototype-build-pr13308-1e6f712.apk

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Jan 14, 2025

📲 You can test the changes from this Pull Request in WooCommerce Android by scanning the QR code below to install the corresponding build.

App Name WooCommerce Android
Platform📱 Mobile
FlavorJalapeno
Build TypeDebug
Commit1e6f712
Direct Downloadwoocommerce-prototype-build-pr13308-1e6f712.apk

@hichamboushaba hichamboushaba force-pushed the issue/3974-remove-xmlrpc-account-mismatch branch from 7155f5b to 72481db Compare January 15, 2025 09:32
@hichamboushaba hichamboushaba changed the title [Login] Remove dependance on XMLRPC for the Account Mismatch flow [Login] Remove dependency on XMLRPC for the Account Mismatch flow Jan 15, 2025
@hichamboushaba hichamboushaba marked this pull request as ready for review January 15, 2025 09:46
@hichamboushaba hichamboushaba added this to the 21.5 milestone Jan 15, 2025
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 46.87500% with 17 lines in your changes missing coverage. Please review.

Project coverage is 41.15%. Comparing base (3222339) to head (be1d308).
Report is 11 commits behind head on trunk.

Files with missing lines Patch % Lines
...login/accountmismatch/AccountMismatchRepository.kt 48.38% 7 Missing and 9 partials ⚠️
...n/accountmismatch/AccountMismatchErrorViewModel.kt 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##              trunk   #13308      +/-   ##
============================================
+ Coverage     41.10%   41.15%   +0.05%     
- Complexity     6421     6429       +8     
============================================
  Files          1321     1321              
  Lines         77177    77135      -42     
  Branches      10643    10640       -3     
============================================
+ Hits          31722    31744      +22     
+ Misses        42646    42572      -74     
- Partials       2809     2819      +10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@irfano irfano self-assigned this Jan 16, 2025
@irfano
Copy link
Contributor

irfano commented Jan 16, 2025

Prepare a site that has two wp-admin users, one is connected to Jetpack (user A) and the other not (user B).

@hichamboushaba, I couldn't test the case because I seem to be missing something. Can you help me figure out what I’m overlooking?

  • I created a JN site.
  • I added a second user, "User A" in addition to the default demo account.
  • I logged into the site with "User A" on mobile and connected the site to Jetpack using my "WP account A".
  • Logged out of the app.
  • Disabled XMLRPC on the site.
  • Entered the site address in the app.
  • Entered a random WP account to trigger the mismatch account screen.
  • Tapped "Connect Jetpack to your account" button on the mismatch account screen.
  • Then I used the “demo” user credentials to log in but failed.

I'm a bit confused here.

@hichamboushaba
Copy link
Member Author

Then I used the “demo” user credentials to log in but failed.

Thanks for the review @irfano, when you say failed, what do you mean? A screen recording and app logs would be great to understand the issue.

@irfano
Copy link
Contributor

irfano commented Jan 16, 2025

I guess I was using the wrong password. I was able to reproduce the issue on trunk, and it works on this PR. I’m reviewing the code changes now.

Copy link
Contributor

@irfano irfano left a comment

Choose a reason for hiding this comment

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

I wasn’t familiar with this area of the app, so it took some time. Looks good to me! 👍🏻

@hichamboushaba hichamboushaba merged commit 51f62d3 into trunk Jan 17, 2025
15 checks passed
@hichamboushaba hichamboushaba deleted the issue/3974-remove-xmlrpc-account-mismatch branch January 17, 2025 10:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature: login Related to any part of the log in or sign in flow, or authentication. type: enhancement A request for an enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ParseError: org.xmlpull.v1.XmlPullParserException: Unexpected token
4 participants