How to use secure way to store password in database with Node.js and Express

1 Answer

0 votes
const express = require('express');
const bcrypt = require('bcryptjs');
 
const router = express.Router();
 

router.post(
  '/',
  async (req, res) => {
    let user = ({
      email,
	  password,
    } = req.body);

    const salt = await bcrypt.genSalt(10);
    user.password = await bcrypt.hash(user.password, salt);
	  
	return res.json(user.password);
  }
);

 



answered May 15, 2020 by avibootz

Related questions

1 answer 269 views
1 answer 108 views
3 answers 353 views
...