vidly-api-node icon indicating copy to clipboard operation
vidly-api-node copied to clipboard

Solution to those who are not able to POST 'users' data to the DB or the 'bcrypt' error.

Open harshit-jain13 opened this issue 4 years ago • 4 comments

Just install 'bcrypt' if not already or check if already installed. npm i bcrypt

Now, in your vidly-api-node folder goto routes folder and open up users.js in your code editor. and change this code (probably on line 21 & 22): const salt = await bcrypt.genSalt(10); user.password = await bcrypt.hash(user.password, salt); with this: const saltRounds = 10; const myPlaintextPassword = user.password; const bcrypt = require("bcrypt"); const salt = bcrypt.genSaltSync(saltRounds); const hash = bcrypt.hashSync(myPlaintextPassword, salt); user.password = hash; Save the file and you are good to go :)

harshit-jain13 avatar Jan 09 '21 10:01 harshit-jain13

Try to use the bcryptjs npm package.

dansalahi avatar Jan 18 '21 06:01 dansalahi

I tried but it did not work. I even tried using bcrypt-nodejs it didn't work either.

harshit-jain13 avatar Jan 18 '21 07:01 harshit-jain13

Do not forget to rerun the script node index.js after changing your code. As I faced this issue.

HafizSaifullah avatar Apr 04 '21 10:04 HafizSaifullah

Fixed bcrypt error using bcrypt version 5.0.0

the-black-viper avatar Jul 19 '21 00:07 the-black-viper