FAC-Sixteen / Week7-project-onions2.0

Week 7 authentication project
http://lost-and-fac.herokuapp.com/
0 stars 2 forks source link

Unhandled Promise in Handler #12

Open RohanSSS opened 5 years ago

RohanSSS commented 5 years ago

the calling of bcrypt.compare on line 29 of the handler will return a promise due to the fact that you haven't given it a callback

const isMatch = bcrypt.compare(password, storedPassword);

This is currently unhandled since you've not done a .then() after it.

if you want to assign the result to a variable you would have to use bcrypt.compareSync

the way its currently set up is that it will call the promise in both if statements running through both and slowing down the code due to the fact it has to do the compare twice.

bcrypt.compare(password, storedPassword)
    .then(res => {do stuff here})

will take the resolve from the comparison forward at which point you could do the checking for whether it was true or false