[openstreetmap/openstreetmap-website] Add some javascript to check dynamically if the username is already taken (PR #4402)

Andy Allan notifications at github.com
Wed Dec 13 17:05:21 UTC 2023


@pietervdvn Thanks for your PR. I agree that this sort of thing could be useful for people signing up, particularly since we're a large project with many existing registrations so users are increasingly likely to find their first-choice display_name is already taken.

However, there's a few things with this specific implementation that would need to be considered:
* display_name checking - this can't just be done against the user profile page. Firstly, it's not designed as a lightweight endpoint, there is a lot of stuff being rendered on that page. Although using HEAD will reduce the payload, I don't think it's a good idea to call HEAD on full pages for every keystroke - the latency is likely to be too high. A better approach would be a specific endpoint, e.g. a json endpoint that only does one thing. 
* display_name checking - this also can't be done against the user profile page, due to unconfirmed users, suspended users and deleted users. These are pages that will return a 404, but the display_name is already taken. 
* Lack of tests - this needs to have some decent tests, otherwise any breakage (e.g. due to refactoring) is not going to be noticed by developers - we rarely sign up for new accounts!
* This is "ad-hoc client-side validation" and in general that makes me hesitant. Particularly for things like character validation rules, it would be much better to drive the client-side validation from the existing model validations. Sure, this particular PR is simply for just one field on just one form, but if we write ad-hoc code we'll end up with a ton of javascript to maintain when we want to roll this out to other fields and/or other forms. So I would like to know more about what options there are in the rails ecosystem (e.g. https://github.com/judgegem/judge or others ) that can do this properly, with less custom code for us to maintain.
* Accessibility - I'm vaguely aware of there being [APIs in modern HTML to do client-side validation](https://developer.mozilla.org/en-US/docs/Learn/Forms/Form_validation), and this is likely to be more involved than just flipping a class on an element. But I'm not an expert on that. If we used a framework to do this, that project team would likely have more expertise on this topic than we have.
* Textual feedback - I would want to see the same text feedback on what the errors are when done both client-side and server-side. Just adding the class isn't enough to guide the users as to what is wrong and what they need to do to fix it.



-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/4402#issuecomment-1854374602
You are receiving this because you are subscribed to this thread.

Message ID: <openstreetmap/openstreetmap-website/pull/4402/c1854374602 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20231213/e47ea638/attachment.htm>


More information about the rails-dev mailing list