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

set email validator to lowercase #7645

Merged
merged 10 commits into from Sep 14, 2020
Merged

Conversation

bglidwell
Copy link
Contributor

Description of what you did:

Yup .lowercase() converts the string to lowercase which should be done in all instances of email across the application.

Fixes bug where users created inside Strapi admin panel end up with mixed case emails in database.

@codecov
Copy link

codecov bot commented Aug 30, 2020

Codecov Report

Merging #7645 into master will increase coverage by 0.03%.
The diff coverage is 58.82%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #7645      +/-   ##
==========================================
+ Coverage   27.16%   27.20%   +0.03%     
==========================================
  Files        1163     1164       +1     
  Lines       15518    15519       +1     
  Branches     2410     2412       +2     
==========================================
+ Hits         4216     4222       +6     
+ Misses       9534     9528       -6     
- Partials     1768     1769       +1     
Flag Coverage Δ
#front 19.36% <62.50%> (+0.04%) ⬆️
#unit 53.85% <0.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...admin/admin/src/components/ContainerFluid/index.js 66.66% <ø> (ø)
...in/src/components/LeftMenu/LeftMenuFooter/index.js 33.33% <0.00%> (-33.34%) ⬇️
...trapi-admin/admin/src/validations/users/profile.js 50.00% <ø> (ø)
...kages/strapi-admin/validation/common-validators.js 79.16% <ø> (ø)
...rc/containers/EditViewDataManagerProvider/index.js 0.00% <0.00%> (ø)
.../admin/src/components/ComponentIconPicker/index.js 0.00% <0.00%> (ø)
...agerProvider/utils/retrieveComponentsFromSchema.js 68.75% <ø> (ø)
...ugin-upload/admin/src/components/EditForm/index.js 0.00% <0.00%> (ø)
...rapi-plugin-upload/admin/src/translations/index.js 0.00% <ø> (ø)
packages/strapi-provider-upload-local/lib/index.js 29.16% <0.00%> (ø)
... and 5 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cd9296b...448bcbb. Read the comment docs.

@soupette
Copy link
Contributor

@bglidwell thanks a lot for your contribution! Before reviewing your PR can you make sure the DCO checks?
Also, do you mind updating the front-end validations so it matches the back-end ones? Here's the corresponding file

Yup .lowercase() converts the string to lowercase which should be done in all instances of email across the application.

Fixes bug where users created inside Strapi admin panel end up with mixed case emails in database.

Signed-off-by: bglidwell <sintex+github@gmail.com>
Removed .min(5) from backend validation due to redundancy with .email() check

Signed-off-by: bglidwell <sintex+github@gmail.com>
@bglidwell
Copy link
Contributor Author

@soupette done!

Copy link
Contributor

@soupette soupette left a comment

Choose a reason for hiding this comment

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

LGTM to me for the front-end part.

Signed-off-by: Bobby Glidwell <sintex+github@gmail.com>
@bglidwell
Copy link
Contributor Author

Worth noting, this optimization can be used in a lot of different areas. I scoped this particular PR to just the users & permissions plugin for simplicity. I think this route makes schemas easier to test.

This reverts commit 4565054.

Signed-off-by: Bobby Glidwell <sintex+github@gmail.com>
@bglidwell
Copy link
Contributor Author

bglidwell commented Sep 3, 2020

Interesting that the backend doesn't also use yup for validation. Seems a lot of that could be shared between FE/BE, reducing complexity and improving consistency.

It appears the admin panel uses a different controller, so that needed to be updated with toLowerCase() as well. I feel the plugin itself could use some more work.

Signed-off-by: Bobby Glidwell <sintex+github@gmail.com>
Signed-off-by: Bobby Glidwell <sintex+github@gmail.com>
Signed-off-by: Bobby Glidwell <sintex+github@gmail.com>
Copy link
Contributor

@soupette soupette left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue: enhancement Issue suggesting an enhancement to an existing feature source: core:admin Source is core/admin package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants