Information Security with HelmetJS - Hash and Compare Passwords Asynchronously

Information Security with HelmetJS - Hash and Compare Passwords Asynchronously
0

#1

I am failing this one and only test case:

Async hash generated and correctly compared

And the error log says

Nested within the hash function should be the compare function comparing myPlaintextPassword to hash

Here is my code. Can I get some help please?

bcrypt.hash(myPlaintextPassword, saltRounds, (err, hash) => {
  console.log(hash); 
  bcrypt.compare(someOtherPlaintextPassword, hash, (err, res) => {
      console.log(res); 
  });
});

#2

Figured it out. I had to compare myPlaintextPassword with itself not something different.


#3

I’m hitting a similar error on this lesson, but from what I can tell my code is correct. I hit an odd bug on an earlier lesson in this module, so I’m wondering if that’s the case again. Here is my code:

bcrypt.hash(myPlaintextPassword, saltRounds, (err, hash) => {
  console.log(hash);
//END_ASYNC

//START_SYNC
  bcrypt.compare(myPlaintextPassword, hash, (err, res) => {
  console.log(res);
  });
});

And here is a link to my project:

Any ideas on what might be causing my issue?


#4

Never mind, I found the issue for mine as well.

All of the code from that lesson should be contained within the //START_ASYNC and //END_ASYNC comments.

//START_SYNC and //END_SYNC block is entirely for the next lesson.