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

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

Open
harshit-jain13 opened this issue Jan 9, 2021 · 4 comments

Comments

@harshit-jain13
Copy link

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 :)

@dansalahi
Copy link

Try to use the bcryptjs npm package.

@harshit-jain13
Copy link
Author

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

@HafizSaifullah
Copy link

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

@the-black-viper
Copy link

Fixed bcrypt error using bcrypt version 5.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants