Skip to content
This repository was archived by the owner on Dec 14, 2023. It is now read-only.

Commit bed58e0

Browse files
committed
new util function copying profile hash encode algorithm
1 parent be56051 commit bed58e0

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

lib/profile-utils.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const bcrypt = require('bcryptjs');
2+
const saltRounds = process.env.NODE_ENV == 'test' ? 5 : 12;
3+
4+
const encodePassword = async input => {
5+
const salt = await bcrypt.genSalt(saltRounds);
6+
7+
return await bcrypt.hash(input, salt);
8+
};
9+
10+
module.exports = { encodePassword };

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
},
2929
"dependencies": {
3030
"async": "0.9.0",
31+
"bcryptjs": "2.4.3",
3132
"camelcase": "^4.1.0",
3233
"cp-i18n-lib": "git+https://github.com/CoderDojo/cp-i18n-lib.git",
3334
"cp-logs-lib": "git://github.com/CoderDojo/cp-logs-lib#1.1.0",

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,11 @@ bcrypt-pbkdf@^1.0.0:
479479
dependencies:
480480
tweetnacl "^0.14.3"
481481

482+
483+
version "2.4.3"
484+
resolved "https://registry.yarnpkg.com/bcryptjs/-/bcryptjs-2.4.3.tgz#9ab5627b93e60621ff7cdac5da9733027df1d0cb"
485+
integrity sha1-mrVie5PmBiH/fNrF2pczAn3x0Ms=
486+
482487
483488
version "0.3.1"
484489
resolved "https://registry.yarnpkg.com/big-number/-/big-number-0.3.1.tgz#ac73020c0a59bb79eb17c2ce2db77f77d974e013"

0 commit comments

Comments
 (0)