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

Add registration submission prevention for backend checks #9267

Conversation

rebecca-shoptaw
Copy link
Collaborator

@rebecca-shoptaw rebecca-shoptaw commented May 14, 2024

Closes #9264.

Feature. Prevents registration form submission if any inputs are invalid -- covers taken username/screenname errors which would otherwise pass HTML checks and allow submission.

Technical

Adds an extra validity check (determining that no form inputs are invalid) before allowing form submission. This means that inputs that are invalid because they failed backend IA/OL availability checks, but passed HTML formatting tests, will still be caught and prevent form submission.

This strategy has the added advantage of ensuring any future JavaScript-based checks (i.e. if we move the email spamcheck into realtime_account_validation.js) will automatically prevent form submission, as long as they assign the input an invalid class.

As noted in the issue, this won't display helpful new error messages the way the HTML checks does, but further UI customization (i.e. highlighting existing error messages) could be included in the UI phase of #7694.

Also has a nice side effect of handling the edge case in where a user's browser doesn't support reportValidity -- if their submission has formatting issues, they won't see the nice HTML errors, but they still won't be able to submit.

Also added a few comments to explain what these checks do to prevent future developers removing seemingly duplicative checks.

Testing

  1. Log out (if logged in)
  2. Go to "Sign Up" or /account/create
  3. Fill in all the inputs, ensuring that you pass all formatting checks, but that you enter a username or email that is taken on IA or OL -- feel free to use rebecca@rebeccashoptaw.dev or rstesting for testing purposes
  4. The form should not submit

Screenshot

Stakeholders

@cdrini @mekarpeles

@rebecca-shoptaw rebecca-shoptaw added the State: Blocked Work has stopped, waiting for something (Info, Dependent fix, etc. See comments). [managed] label May 15, 2024
@rebecca-shoptaw rebecca-shoptaw force-pushed the 9264/feature/add-submission-prevention-for-backend-checks branch from 9f1bf5c to 340e0cc Compare May 24, 2024 13:59
@rebecca-shoptaw rebecca-shoptaw removed the State: Blocked Work has stopped, waiting for something (Info, Dependent fix, etc. See comments). [managed] label May 24, 2024
@cdrini cdrini added the On testing.openlibrary.org This PR has been deployed to testing.openlibrary.org for testing label May 24, 2024
@rebecca-shoptaw rebecca-shoptaw force-pushed the 9264/feature/add-submission-prevention-for-backend-checks branch from 340e0cc to 38042dc Compare May 24, 2024 14:46
@rebecca-shoptaw rebecca-shoptaw marked this pull request as ready for review May 24, 2024 14:53
Copy link
Collaborator

@cdrini cdrini left a comment

Choose a reason for hiding this comment

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

Sweet! Tested taken email and it did prevent the form submitting. Tested non-taken and it went through.

Note: The sign up button takes a spell! Might be a good future extension to have a loading indicator.

@cdrini cdrini merged commit 10f75fa into internetarchive:master May 29, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
On testing.openlibrary.org This PR has been deployed to testing.openlibrary.org for testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Prevent registration form submission if backend checks fail (i.e. taken IA/OL username or email address)
2 participants