Freecodecamp: Capitalized letters in username silently gets converted to lowercase

Created on 25 Sep 2020  路  15Comments  路  Source: freeCodeCamp/freeCodeCamp

Describe the bug

While writing tests with Cypress, I found that in the /settings page when you try to change your username with a capital letter, it silently get's converted to lowercase. For example: if Quincy was input, it get's converted to quincy.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '/setting'
  2. Click on the username change input and enter a username with capital letter
  3. Click Save
  4. See the issue

Expected behavior

It should show an error message or warn the user that capital letters in name will get converted to lowercase.

help wanted

Most helpful comment

Since we haven't had any objections lets go with Username (lowercase only).

All 15 comments

I'm seeing this in the actual input box itself. When I type "NHCARRIGAN", the input box shows "nhcarrigan" even before save.

This behavior is intentional. At the minute we have a bug with case sensitivity and it works best if usernames are in small case.

I figured the behaviour was intentional, but should it be silent?
Maybe a note above/below the input that says "must be all lowercase letters"?

Maybe a note above/below the input that says "must be all lowercase letters"?

Yes, it could be part of the validation message. A PR is welcome to clear up the confusion.

This line makes it lowercase:

https://github.com/freeCodeCamp/freeCodeCamp/blob/4e51e845bb1fd3d044ccc2b7a121584d172f5ebd/client/src/components/settings/Username.js#L99

This is something which we want to keep because of the current limitations.

But I am not sure about yet another alert type info, because already have a couple which would clutter the UI

image

Hey @ahmadabdolsaheb could you guide here?

I think that Username (lowercase only) should be enough. (We could also use Username (lowercase alphanumeric only) if we want to be more explicit.)

Since we haven't had any objections lets go with Username (lowercase only).

We could go with:

image

but have the text "Characters must be lowercase". So, rather than transforming each character, we just validate in the usual way.

So... have a warning like that would suffice?

@Twaha-Rahman it seems odd to treat capitals differently from any other symbol we're not allowing. With that in mind I think we should just have a warning like that and remove https://github.com/freeCodeCamp/freeCodeCamp/blob/4e51e845bb1fd3d044ccc2b7a121584d172f5ebd/client/src/components/settings/Username.js#L99

@raisedadead is that reasonable?

If we do want to remove the forced lowercasing in that input field we want to make sure its lowercased elsewhere before being sent to the API.

Sure. What I'm suggesting is that it's forced to be lowercase by validation, so you can't click submit until all the characters are lowercase.

To be on the safe side, I think we should validate in here

https://github.com/freeCodeCamp/freeCodeCamp/blob/a48ed627adaeed622a099b87d990d917b65a7561/api-server/common/models/user.js#L730

as well.

I'll be getting back to this after I get #39622 merged. That way I can add the tests for this feature in this PR.

Thanks, Twaha. Take whatever time you need.

Personnality I think this is nice like that. Nothing to do!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

raisedadead picture raisedadead  路  3Comments

trashtalka3000 picture trashtalka3000  路  3Comments

QuincyLarson picture QuincyLarson  路  3Comments

Tzahile picture Tzahile  路  3Comments

EthanDavis picture EthanDavis  路  3Comments