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

#160690389 remove username from required signup details and make it updateable #36

Merged
merged 35 commits into from
Sep 27, 2018

Conversation

madeofhuman
Copy link
Contributor

@madeofhuman madeofhuman commented Sep 22, 2018

What does this PR do?

Removes the username property from required data for user signup, automatically create a username for the user from their first name, and make the username property updateable

Description of Task to be completed?

  • remove username property from required data for user signup
  • automatically create a username for the user from their first name
  • make the username property updateable

How should this be manually tested?

  1. Clone the repository
  2. Use the .env.example to fill in the .env file
  3. Startup the command line
  4. Run npm install
  5. Run npm start
  6. Make a POST request to /api/v1/auth/signup and create an account with the properties firstName, lastName, email, password, and confirmPassword. The username property will be automatically generated from your first name and added to your user details on creation.
  7. Make a PUT request to /api/v1/users/:username and update your profile with the properties firstName, lastName, email, username, password, and confirmPassword. Note that your email address will cannot be changed.

Any background context you want to provide?

  • The username field was removed from the signup process so we can reduce the amount of information the user had to supply.

What are the relevant pivotal tracker stories?

Screenshots (if appropriate)

N/A

Questions:

N/A

[Delivers #160690389]

- remove username requirement in req.body for user signup
- automatically create username from firstname
- remove tests that depend on presence of username in req.body
[Delivers #160690389]
- make username updateable
- add tests for this functionality
- modify error handler to return custom error message param in next()
[Delivers #160690389]
@coveralls
Copy link

coveralls commented Sep 22, 2018

Pull Request Test Coverage Report for Build 436

  • 10 of 11 (90.91%) changed or added relevant lines in 3 files are covered.
  • 2 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.3%) to 94.99%

Changes Missing Coverage Covered Lines Changed/Added Lines %
server/index.js 1 2 50.0%
Files with Coverage Reduction New Missed Lines %
server/v1/controllers/ProfileController.js 1 95.92%
server/v1/controllers/AuthController.js 1 91.25%
Totals Coverage Status
Change from base Build 416: 0.3%
Covered Lines: 719
Relevant Lines: 743

💛 - Coveralls

- add jsdoc for createUsername function
- properly handle errors with the next() function
[Fixes #160690389]
- properly test the createusername function
[Delivers #160690389]
server/v1/controllers/AuthController.js Outdated Show resolved Hide resolved
- remove unused argument when calling the createUsername method
[Fixes #160690389]
- exclude user password from returned search data
[Fixes #159204729]
Copy link
Contributor

@chukwuemekachm chukwuemekachm left a comment

Choose a reason for hiding this comment

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

Well done, @madeofhuman.
I like how you created a separate method to help create a username for a new user in lieu of adding the logic to the signup user method. This makes the code neat.
However, I feel you should also create a method or mechanism to ensure that the username is always unique and belongs to a single user. This is because the username field on our User model has a unique constraint and if a user tries to update their profile with a username which already belongs to another user the operation/database will crash.
Please endeavour to resolve this.
Good job.

- return an error when user tries to update their username to an already exisiting one
- increase test timeout to accommodate slow network calls
[Fixes #160690389]
@madeofhuman
Copy link
Contributor Author

Thanks for pointing that out, @chukwuemekachm . I have fixed it.

- test more edge cases for username update
[Delivers #160690389]
Copy link
Contributor

@chukwuemekachm chukwuemekachm left a comment

Choose a reason for hiding this comment

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

Welldone @madeofhuman.

- remove username requirement in req.body for user signup
- automatically create username from firstname
- remove tests that depend on presence of username in req.body
[Delivers #160690389]
- make username updateable
- add tests for this functionality
- modify error handler to return custom error message param in next()
[Delivers #160690389]
- add jsdoc for createUsername function
- properly handle errors with the next() function
[Fixes #160690389]
- properly test the createusername function
[Delivers #160690389]
- remove unused argument when calling the createUsername method
[Fixes #160690389]
- exclude user password from returned search data
[Fixes #159204729]
- return an error when user tries to update their username to an already exisiting one
- increase test timeout to accommodate slow network calls
[Fixes #160690389]
- test more edge cases for username update
[Delivers #160690389]
…ndela/elven-ah into feature/160690389/user-update-username
Copy link
Contributor

@Veraclins Veraclins left a comment

Choose a reason for hiding this comment

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

@madeofhuman Good job here! @chukwuemekachm has raised the only concern I had and you have fixed that. So kudos and keep it up!

…ndela/elven-ah into feature/160690389/user-update-username
…ndela/elven-ah into feature/160690389/user-update-username
@madeofhuman madeofhuman force-pushed the feature/160690389/user-update-username branch from 6575255 to 49f9617 Compare September 27, 2018 09:28
@tonymontaro
Copy link
Contributor

@madeofhuman change the base branch to develop

- remove username requirement in req.body for user signup
- automatically create username from firstname
- remove tests that depend on presence of username in req.body
[Delivers #160690389]
- make username updateable
- add tests for this functionality
- modify error handler to return custom error message param in next()
[Delivers #160690389]
- add jsdoc for createUsername function
- properly handle errors with the next() function
[Fixes #160690389]
- properly test the createusername function
[Delivers #160690389]
- remove unused argument when calling the createUsername method
[Fixes #160690389]
- exclude user password from returned search data
[Fixes #159204729]
- return an error when user tries to update their username to an already exisiting one
- increase test timeout to accommodate slow network calls
[Fixes #160690389]
- test more edge cases for username update
[Delivers #160690389]
- remove username requirement in req.body for user signup
- automatically create username from firstname
- remove tests that depend on presence of username in req.body
[Delivers #160690389]
- add jsdoc for createUsername function
- properly handle errors with the next() function
[Fixes #160690389]
- test more edge cases for username update
[Delivers #160690389]
- update callback url for Facebook and Google
[Fixes #160056182]
…ndela/elven-ah into feature/160690389/user-update-username
@madeofhuman madeofhuman changed the base branch from staging to develop September 27, 2018 09:53
@madeofhuman
Copy link
Contributor Author

@madeofhuman change the base branch to develop

I have done that. I had to rebase on develop first. @tonymontaro

…ndela/elven-ah into feature/160690389/user-update-username
…ndela/elven-ah into feature/160690389/user-update-username
- add more test for username update
[Fixes #160690389]
Copy link
Contributor

@tonymontaro tonymontaro left a comment

Choose a reason for hiding this comment

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

Nice work!

@tonymontaro tonymontaro merged commit 7422a88 into develop Sep 27, 2018
@tonymontaro tonymontaro deleted the feature/160690389/user-update-username branch September 27, 2018 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants