strapi icon indicating copy to clipboard operation
strapi copied to clipboard

Invite new user: email with camel case error

Open marco-villanueva opened this issue 3 years ago • 4 comments

Bug report

Required System information

  • Node.js version: 16.15.0
  • NPM version: 8.3.0
  • Strapi version: 4.1.8
  • Database: PosgreSQL
  • Operating system: Window 10

Describe the bug

When creating a new admin user (invite new user), if the email has any capital letters, it does not submit the form or show errors. In Network (DevTools) it shows a 400 error.

Is there a sanitizer or something that does a toLowerCase to avoid this error?

Steps to reproduce the behavior

  1. Go to Settings / Users
  2. Click on "Invite new user"
  3. Fill the form with an email like "[email protected]"
  4. Click on "Invite user"
  5. You can repeat it with the network open.

Expected behavior

The form field automatically saves lower cases only.

marco-villanueva avatar May 19 '22 21:05 marco-villanueva

Odd it should just be lowercasing it and not validating the input :thinking:

derrickmehaffy avatar May 24 '22 15:05 derrickmehaffy

Odd it should just be lowercasing it and not validating the input 🤔

In standard scenarios, you are indeed lowercasing the email as per this line, but the defaultValidationParams are enforcing strict checks on the email, which apparently enforces lowercase() to only check that the string is in fact lowercase without transforming it beforehand according to Yup's documentation.

WalkingPizza avatar May 25 '22 21:05 WalkingPizza

@derrickmehaffy do we need to make the change on the frontend on the form or the backend ?

jaysoni-ash42 avatar Aug 04 '22 11:08 jaysoni-ash42

All emails should be lowercase no matter the location so if you want to do the translation on the frontend that's fine, we also should be doing it on the backend.

Doesn't particularly matter if we force the user to type it that way or if we just convert it for them but we should pick something.

derrickmehaffy avatar Aug 04 '22 16:08 derrickmehaffy