Improve username handling with password autofill #17720
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #17696. This PR makes some improvements to the handling of password manager entries that contain usernames instead of email addresses.
Please see also the associated WordPress Authenticator PR wordpress-mobile/WordPressAuthenticator-iOS#630
While we require an email address via the UI in the app (iirc it's because it's typically easier for a user to remember correctly), it's always been technically possible to login using a username. You can do this if your password manager contains an username instead of an email address.
#17696 picked up a couple of odd edge cases if you navigate back during the process:
loginFields.usernameproperty would have been updated to the username of the account resulting in a mismatch between the UI and the submitted data.I've added a couple of tweaks to improve each of these points:
loginFields.usernamefield matches whatever is currently in the email field. This essentially 'resets' any changes made under the hood on the password screen, so the user can have confidence that the UI is correct.2 and 3. The situation in 2 should actually now no longer happen because the email address is correctly validated. However, I've provided a separate error message if we're just validating the form vs validating to request a magic link. I have been unable to find a use case where this happens, as the continue button is disabled if the email isn't valid, but I've included it for completeness:
To test
Finally, ensure that you can log in normally by typing your details and also by completing an autofill successfully from the beginning.
Regression Notes
The changes here are very minimal, but of course they touch the login flow which is one of the most critical flows of the app.
I ensured that I could still log in as before, and ran the UI tests.
None
PR submission checklist:
RELEASE-NOTES.txtif necessary.