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

Implementing password hashing #69

Merged
merged 13 commits into from
Mar 20, 2022
Merged

Conversation

kimslor
Copy link
Contributor

@kimslor kimslor commented Mar 19, 2022

Description

A password hashing method was created in the user models.
This method has been used to hash the plain text password provided by the user during account creation.
Now the hashedPassword will be stored in the DB and not the plaintext password.
This hashPassword() method should be used for password verification, such as login.

salted-md5 was used for the hashing of the plaintext password.

Related Issue

Solves #40

Type of change

  • New feature (enhancement)
  • Refactoring

How Has This Been Tested?

A unit test has been made for this method when a forum user is created and the hashed password stored in the test database is compared with a hashed password using the same plaintext and hashing method.

  • Automated testing

Checklist:

  • Does a similar (open or closed) pull request not already exist?
  • Is the pull request head repository a fork repository?
  • Is the pull request compare branch a development branch?
  • Is the code documented, particularly in hard-to-understand areas?
  • Does the code build without new warnings?
  • Has testing been performed that proves changes are effective and work?
  • Has a self- and/or peer-review of the code been performed?
  • Have dependent changes been merged and published in downstream modules?
  • Does all new and existing automated testing pass?
  • Is the person responsible for the repository assigned to the pull request?
  • Is the pull request linked to a project?
  • Is the pull request linked to a milestone?

For more information, refer to the Contributing Guidelines and Code of Conduct links at the bottom of this page.

@kimslor kimslor added the enhancement New feature or request label Mar 19, 2022
@kimslor kimslor added this to the Assignment 1 milestone Mar 19, 2022
@kimslor kimslor requested a review from a team as a code owner March 19, 2022 23:51
@kimslor kimslor added this to In progress in Team 5 - Assignment 1 - Backend via automation Mar 19, 2022
Copy link
Contributor

@R055A R055A left a comment

Choose a reason for hiding this comment

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

Awesome! Thank you for fixing the test bug. I have left some comments to consider, please

controllers/user.server.controller.js Outdated Show resolved Hide resolved
controllers/user.server.controller.js Outdated Show resolved Hide resolved
models/user.server.model.js Outdated Show resolved Hide resolved
models/user.server.model.js Outdated Show resolved Hide resolved
models/user.server.model.js Outdated Show resolved Hide resolved
models/user.server.model.js Outdated Show resolved Hide resolved
models/user.server.model.js Outdated Show resolved Hide resolved
Copy link
Contributor

@R055A R055A left a comment

Choose a reason for hiding this comment

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

Some changes are required to fix the merge conflict, those mentioned in comments and:

Lines 39, 66, and 94 in test/authenticate.user.test.js:

password = 'authentication-test';

Requires being changed to:

password = 'authentication-test';
hashedPassword = hashPassword('authentication-test');

Line 52 in test/authenticate.user.test.js:

 assert.equal(result.email === email && result.hashedPassword === password, true)

Requires being changed to:

 assert.equal(result.email === email && result.hashedPassword.match(hashedPassword), true)

Line 79 in test/authenticate.user.test.js:

 assert.equal(result.username === username && result.hashedPassword === password, true)

Requires being changed to:

 assert.equal(result.username === username && result.hashedPassword.match(hashedPassword), true)

Line 52, 79, and 109 in test/authenticate.user.test.js:

 assert.equal(result.email === email &&
                        result.username === username && result.hashedPassword === password, true);

Requires being changed to:

 assert.equal(result.email === email &&
                        result.username === username && result.hashedPassword.match(hashedPassword), true);

The hashPassword() function will also require being imported for this file.

test/user.test.js Outdated Show resolved Hide resolved
test/user.test.js Show resolved Hide resolved
@R055A R055A linked an issue Mar 20, 2022 that may be closed by this pull request
@R055A R055A self-requested a review March 20, 2022 04:06
@R055A
Copy link
Contributor

R055A commented Mar 20, 2022

41 tests failed! I have rerun the CI as it is very likley the CI tests failed because of commit(s) made before testing from prior commit(s) has completed causing a clash between test suites executing and accessing the same resources in parallel. I will wait until the final commit has been made and all CI tests are passing before I review again.

@R055A
Copy link
Contributor

R055A commented Mar 20, 2022

41 tests failed! It is likely because of commit(s) made before testing from prior commit(s) has completed causing a clash between test suites executing and accessing the same resources in parallel. I will wait until the final commit has been made and all CI tests are passing before I review again.

Now 31 tests are failing. Let me know when this is ready for review again, please.

Team 5 - Assignment 1 - Backend automation moved this from In progress to Reviewer approved Mar 20, 2022
@R055A R055A merged commit b2016c0 into SE701-T5:main Mar 20, 2022
Team 5 - Assignment 1 - Backend automation moved this from Reviewer approved to Done Mar 20, 2022
@R055A R055A added the invalid This doesn't seem right label Mar 21, 2022
@R055A R055A moved this from Done to Not done in Team 5 - Assignment 1 - Backend Mar 21, 2022
@R055A R055A moved this from Not done to Done in Team 5 - Assignment 1 - Backend Mar 21, 2022
@R055A R055A removed the invalid This doesn't seem right label Mar 21, 2022
@R055A
Copy link
Contributor

R055A commented Mar 21, 2022

I don't know how it happened but I seem to have mistakenly labelled this already merged pull request as invalid. It is not invalid. I have removed the label and moved the pull request back the Done column. I must have had too many tabs open at once.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

Implement a password hashing method
2 participants