aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMateja <mail@matejamaric.com>2021-05-06 22:22:27 +0200
committerMateja <mail@matejamaric.com>2021-05-06 22:22:27 +0200
commit3237737dc88ebff88c258972ac902f9221a003b5 (patch)
tree8c251c067465f8acfd641759268ee4d4d6ddf790
parent143755e5e8a53eeee9f5b2fa7e3b76866c9673d7 (diff)
downloadnode-playground-3237737dc88ebff88c258972ac902f9221a003b5.tar.gz
node-playground-3237737dc88ebff88c258972ac902f9221a003b5.zip
Hash passwords.
-rw-r--r--controllers/user.js3
-rw-r--r--package-lock.json5
-rw-r--r--package.json1
3 files changed, 8 insertions, 1 deletions
diff --git a/controllers/user.js b/controllers/user.js
index 54b8161..980fc12 100644
--- a/controllers/user.js
+++ b/controllers/user.js
@@ -1,4 +1,5 @@
const User = require('../models/user');
+const bcrypt = require('bcryptjs');
module.exports = {
@@ -8,7 +9,7 @@ module.exports = {
firstname: req.body.firstname,
lastname: req.body.lastname,
email: req.body.email,
- password: req.body.password
+ password: bcrypt.hashSync(req.body.password)
});
newUser.save().then(() => {
req.flash('msg', 'You successfully registered.');
diff --git a/package-lock.json b/package-lock.json
index ffa1331..e0c9b29 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -124,6 +124,11 @@
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
"integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw=="
},
+ "bcryptjs": {
+ "version": "2.4.3",
+ "resolved": "https://registry.npmjs.org/bcryptjs/-/bcryptjs-2.4.3.tgz",
+ "integrity": "sha1-mrVie5PmBiH/fNrF2pczAn3x0Ms="
+ },
"binary-extensions": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz",
diff --git a/package.json b/package.json
index b5b711a..9a9ea45 100644
--- a/package.json
+++ b/package.json
@@ -10,6 +10,7 @@
"author": "Mateja Maric",
"license": "GPL-3.0",
"dependencies": {
+ "bcryptjs": "^2.4.3",
"connect-flash": "^0.1.1",
"connect-mongo": "^4.4.1",
"dotenv": "^9.0.0",