-
Notifications
You must be signed in to change notification settings - Fork 0
Description
| bcrypt.compare(passwords[1], passwords[0].password, (error, sucess) => { |
For sure you do not always have the luxury of time when it comes to projects, but keep in mind that you could sometimes do things that are not necessary and could've lead to better code readability if done correctly.
Here you're calling passwords[1] that you're expecting that it has the password (String), but later in the same line you're calling passwords[0].password which is obviously and Object, which had lead you to handle this object back in lines 4 through 6
ourLibrary/src/controllers/comparePassword.js
Lines 4 to 6 in 3600662
| if (!passwords[0]) { | |
| reject('email not found'); | |
| } |
So you should imagine someone wanting to reuse this compare function and seeing that they have to pass an array containing a string in the first index but an object containing the prop password with the string value of the password in the second index.
Seems a bit counter intuitive no? Well, it's not a big problem now since you're not reusing it, but bare in mind that you're building up on what you learn now, and now you should do the best you could.
Which in this case is only about changing this line
ourLibrary/src/controllers/checkUser.js
Line 15 in 3600662
| .then(rows => [rows.rows[0], passwordValue]) |