-
Notifications
You must be signed in to change notification settings - Fork 5
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
Add username check to signup form #257
Conversation
Codecov Report
@@ Coverage Diff @@
## development #257 +/- ##
===============================================
+ Coverage 52.66% 53.83% +1.17%
===============================================
Files 14 15 +1
Lines 1088 1133 +45
===============================================
+ Hits 573 610 +37
- Misses 515 523 +8
Continue to review full report at Codecov.
|
This pull request introduces 1 alert when merging a11af41 into dcb08a9 - view on LGTM.com new alerts:
|
assets/js/main.js
Outdated
field.classList.add(`input-field-${exists ? "error" : "success"}`); | ||
const label = field.nextElementSibling; | ||
if (label) { | ||
label.innerText = exists ? `${username} is not available` : ""; |
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.
From UX perspective I think I might actually want to display “username is available” if I’m not adding in checkmark.
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.
const server = require("../../lib/server"); | ||
const { MongoMemoryServer } = require('mongodb-memory-server'); | ||
const { MongoClient } = require("mongodb"); | ||
const bcrypt = require("bcrypt"); |
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 think this can be removed.
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.
Done
Also adapted username length check done in #261 to be used in username check endpoint as well. This is how it would look in frontend if user typed too long of a username before signing up: |
This pull request introduces 3 alerts when merging 1d91699 into caec0af - view on LGTM.com new alerts:
|
- Add message on frontend when username check returns long username error - Add message when username is available - Extract username check from database-ops into a separate method, to be used in /register route handler and in /check_username. Ideally controllers should be calling the method, but for now I think having the check be called in route handler is better than in DB method. - Remove sanitize username and email calls in addUser, which are now useless. Sanitize method to be dealt with in #95 - Add a couple new test cases to check_username to handle username too long and undefined error with username verification
This pull request introduces 2 alerts when merging 60dcf2f into caec0af - view on LGTM.com new alerts:
|
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.
Also leaving a comment to remind myself to check the codecov and LGTM warnings before merging.
This pull request introduces 2 alerts when merging 2fba9e8 into caec0af - view on LGTM.com new alerts:
|
…ndUser - Also add test to check_username to ensure that setting up a MongoDB query with $ character will not work
This pull request introduces 1 alert when merging 4b68922 into caec0af - view on LGTM.com new alerts:
|
…ssed in is a string specifically
This pull request introduces 1 alert when merging 460abfb into caec0af - view on LGTM.com new alerts:
|
…e first one passed. I believe the LGTM check here https://lgtm.com/projects/g/Coteh/simpleimage/rev/pr-f9f55bc57545265fe0b92210ec390456e24bab06 is a false positive. Previous commit prevents arrays from reaching the verifyUsername call. Nonetheless, I have also added this extra handle after looking into this further. I think it would make sense to only check the first username passed in, if multiple were passed in. User should not be passing in multiple usernames ideally, though.
--inspect-brk, unlike --inspect, breaks on start of execution of the script. Seems like this was preventing execution of the line that starts the server. By changing it to --inspect, things are working as expected now.
This pull request introduces 1 alert when merging ce0984b into caec0af - view on LGTM.com new alerts:
|
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.
The final LGTM alert appears to be false positive. Non-string username parameters should not make it to the verifyUsername
check. The handler will either reject it outright, or in the case of an array, will take the first element only and check that one.
Everything else looks good, will merge it in.
… are passed into it. Also rename the function to isValidUsername and add unit tests.
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.
Fixed LGTM alert with another check for username type in the util function itself, and added unit tests as well.
Fixes #14.
When username is available, username field will be green.
When username is not available, username field will be red with error message below.
When long username is submitted, it will look like this. This is acceptable for now.
When other error occurs (e.g. rate limit error), there will be no highlight and no message. It would effectively look like the way it did before. I decided it would be better UX to not show an error in this case.