mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 05:37:34 +03:00
ae336f19cd
- in the event NODE_ENV isn't set, this would throw an error because `startsWith` is a function call on `undefined`
17 lines
431 B
JavaScript
17 lines
431 B
JavaScript
const bcrypt = require('bcryptjs');
|
|
|
|
let HASH_ROUNDS = 10;
|
|
|
|
if (process.env.NODE_ENV?.startsWith('testing')) {
|
|
HASH_ROUNDS = 1;
|
|
}
|
|
|
|
module.exports.hash = async function hash(plainPassword) {
|
|
const salt = await bcrypt.genSalt(HASH_ROUNDS);
|
|
return bcrypt.hash(plainPassword, salt);
|
|
};
|
|
|
|
module.exports.compare = function compare(plainPassword, hashedPassword) {
|
|
return bcrypt.compare(plainPassword, hashedPassword);
|
|
};
|