website
website copied to clipboard
Registration should check for duplicate usernames
When you register an account on the Outreachy website, it asks for a username. Right now, the form validation does not check whether the username is already in use.
That means when someone tries to create a new account with a username that is already in use, a "duplicate key value" error is thrown. The user ends up at an ngix error page with few details on what happened, which is a terrible user experience!
I think the registration form validation is implemented in home/views.py
in class RegisterUserForm
. You'll need to add a validation step to check if the username is already in use.
To test your code, follow the installation instructions and then run the code to create fake data in your local website to make it seem like initial application period is open.
Once you have created this fake data, there will be several accounts created with the following usernames: applicant1, mentor1, etc. See the full list in the instructions linked above. Try to create a new account with one of those usernames. You should be able to trigger the bug. Then write code to fix the bug. Test that your code shows a form error when you try to register with a username that is already in use.
Bonus: write a test to ensure the error appears when a user tries to fill out the registration form with a username that is already in use. There's currently no tests that test the registration system, so adding additional tests to ensure the emails are sent, and that following the link activates the account, would be a major help!
@sagesharp I want to work on this issue.
@Sukriti-sood Welcome! Please make sure to read the Newcomer's Guide and the README.
This is a medium complexity issue, so it may be a bit too complicated for your first issue. I would suggest tackling another issue if you're new to Python and Django.