-
Notifications
You must be signed in to change notification settings - Fork 2
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
Restrict user to use accented characters in username #262
Conversation
Codecov Report
@@ Coverage Diff @@
## main #262 +/- ##
==========================================
- Coverage 91.00% 86.27% -4.73%
==========================================
Files 214 93 -121
Lines 6338 3542 -2796
Branches 314 314
==========================================
- Hits 5768 3056 -2712
+ Misses 483 399 -84
Partials 87 87 Continue to review full report at Codecov.
|
@asadiqbal08 You might need to re-run the tests since the CI is failing. |
users/serializers.py
Outdated
@@ -28,7 +28,7 @@ | |||
""", | |||
flags=re.I | re.VERBOSE | re.MULTILINE, | |||
) | |||
USERNAME_RE_PARTIAL = r"[\w .@_+-]+" | |||
USERNAME_RE_PARTIAL = r"[ A-Za-z0-9.@_+-]+" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although functionality wise it works fine and doesn't allow accented characters, I have two minor things that you might consider here:
- I'm sure there could be a reference to using the space in the username which is unusual but if we do want to use it we should place that somewhere close to the allowed special characters list e.g.
r"[A-Za-z0-9 .@_+-]+"
- Since we are matching the username text through a regex, shouldn't we add this regex validation on the frontend validator(https://github.com/mitodl/mitxonline/blob/main/static/js/lib/validation.js#L20) and we can save us an API call that is just going to tell the users about what characters they can use after hitting the submit button.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know point#2 might not be purely related to the PR but that has a chance to get fixed in this, @gsidebo could even give a better thought on this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@arslanashraf7 regarding the point.2,
- It makes sense to me that there should be
frontend validation
earlier before sending an api call. space
in username does not make sense to me as well. I keep it by considering it may be a requirement earlier but I have removed it and take input from @gsidebo ifspace
really makes sense to be part ofusername
.
kindly take a look over another commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We currently have usernames with spaces. I don't think we need to remove that capability
7a0c15d
to
9d8001e
Compare
Just FYI I'm labeling this "on hold" for a few reasons:
|
Closing this so we can re-implement according to the details in the updated issue (#259) |
Pre-Flight checklist
What are the relevant tickets?
fixes: #259
What's this PR do?
(Required)
How should this be manually tested?
Create a user with username that may have accented characters in it e.g.
önlínê-user
. The system should not allow it.NOTE:
- I did not update the messageUsername can only contain letters, numbers, spaces, and the following characters: @_+-
, seems of enough but if needs to modify then let me know.