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

Commit

Permalink
new util function copying profile hash encode algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeddf committed Dec 13, 2019
1 parent be56051 commit bed58e0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/profile-utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const bcrypt = require('bcryptjs');
const saltRounds = process.env.NODE_ENV == 'test' ? 5 : 12;

const encodePassword = async input => {
const salt = await bcrypt.genSalt(saltRounds);

return await bcrypt.hash(input, salt);
};

module.exports = { encodePassword };
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
},
"dependencies": {
"async": "0.9.0",
"bcryptjs": "2.4.3",
"camelcase": "^4.1.0",
"cp-i18n-lib": "git+https://github.com/CoderDojo/cp-i18n-lib.git",
"cp-logs-lib": "git://github.com/CoderDojo/cp-logs-lib#1.1.0",
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,11 @@ bcrypt-pbkdf@^1.0.0:
dependencies:
tweetnacl "^0.14.3"

[email protected]:
version "2.4.3"
resolved "https://registry.yarnpkg.com/bcryptjs/-/bcryptjs-2.4.3.tgz#9ab5627b93e60621ff7cdac5da9733027df1d0cb"
integrity sha1-mrVie5PmBiH/fNrF2pczAn3x0Ms=

[email protected]:
version "0.3.1"
resolved "https://registry.yarnpkg.com/big-number/-/big-number-0.3.1.tgz#ac73020c0a59bb79eb17c2ce2db77f77d974e013"
Expand Down

0 comments on commit bed58e0

Please sign in to comment.