Skip to content

Improve the error message for invalid site url in login flow#9645

Merged
aforcier merged 2 commits intodevelopfrom
issue/8460-better-error-messaging-for-site-url-in-login
Apr 17, 2019
Merged

Improve the error message for invalid site url in login flow#9645
aforcier merged 2 commits intodevelopfrom
issue/8460-better-error-messaging-for-site-url-in-login

Conversation

@oguzkocer
Copy link
Copy Markdown
Contributor

Fixes #8460. This PR improves the error messages for invalid site url. Instead of relying on the FluxC callback to check if the input text is a valid url, we'll first do a pattern check and if it fails, we'll show login_invalid_site_url message. If the pattern matches a url, we'll let FluxC do it's thing and if finds that there are no sites at that url, it's more likely that it's not a WordPress site, so we show the updated no_site_error message.

There are several different ways to check if it's a valid url, but surprisingly out of all the options I tried, only one of them worked exactly how I want this to. Here are a couple issues:

  • If we use UrlUtils.isValidUrlAndHostNotNull, we'll need to put in the scheme in which case it says it's a valid url when I enter arst (which will be converted to http://arst)
  • URLUtil.isValidUrl() suffers from the same issue above

See: https://stackoverflow.com/a/5930532


Copy Updates

I've requested two different messages from editorial in an internal p2 post and they got back to me with the following messages:

login_invalid_site_url: The site address you entered is invalid. Please re-enter it.
no_site_error: The site at this address is not a WordPress site. For us to connect to it, the site must use WordPress.

I don't think it's necessary to do another editorial review.


Design Review

I brought up this issue on Slack and per @mattmiklic:

On the design side, we should fix the spacing so the error message lines up with the text field and fix the weird line break between “at this” and “address.”

I am not entirely sure why the line break issue was happening, but it seems to be working fine for me. For the spacing, I think it's correct right now, maybe the screenshot in the original issue is a wrong one. Here are screenshots of the updated message with and without the layout bounds:

Screenshot_1555449776
Screenshot_1555449768


To test
Test the following cases:

  1. Empty site url
  2. Any text without .
  3. Any text without a . but with a url scheme such as http://
  4. A valid url that's not a WordPress site
  5. A valid WordPress site url

Here are my tests: https://cloudup.com/coSPbKhY4lU


Update release notes:

- [ ] If there are user facing changes, I have added an item to RELEASE-NOTES.txt.

I don't think this is big enough of a change to have in the release notes, but let me know if you feel otherwise.

@oguzkocer oguzkocer added Login [Status] Needs Design Review A designer needs to sign off on the implemented design. labels Apr 16, 2019
@oguzkocer oguzkocer added this to the 12.3 milestone Apr 16, 2019
@oguzkocer
Copy link
Copy Markdown
Contributor Author

@aforcier I am not sure what the process is like for updating the login library as mentioned on Slack. I thought I'd just open the PR and take it from there. So, I am not touching the lint errors for now.

Copy link
Copy Markdown
Member

@mattmiklic mattmiklic left a comment

Choose a reason for hiding this comment

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

These screenshots look good, thanks for confirming the alignment is right, @oguzkocer.

@oguzkocer oguzkocer removed the [Status] Needs Design Review A designer needs to sign off on the implemented design. label Apr 16, 2019
@aforcier
Copy link
Copy Markdown
Contributor

Works well functionally, tested various URL cases 👍

As I shared on Slack, you'll need to run bundle exec fastlane localize_libs to fix the lint errors (and also overwrite the old version of the no_site_error string, which is currently overwriting your changed version).

The script automatically adds new strings to the bottom of WordPress' strings.xml - you'll probably want to move login_invalid_site_url up to the <!-- Login --> section of the file after running the script.

@oguzkocer
Copy link
Copy Markdown
Contributor Author

Thanks for the review @aforcier! I've manually made the changes as it was taking too long to setup my machine for the script. Hopefully it's fixed now!

@aforcier
Copy link
Copy Markdown
Contributor

:shipit:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Better Error Messaging for Invalid URLs

3 participants