@speakr/speakr-module-services
Version:
SPEAKR Shared Service Module
28 lines (23 loc) • 633 B
JavaScript
;
const bcrypt = require('bcryptjs');
module.exports = {
password
};
function password(options){
return new Promise((resolve, reject) => {
if (options.password == null) {
return reject('Password is blank.');
}
if (options.password != options.password_confirmation) {
return reject('Passwords do not match.');
}
return bcrypt.hash(options.password, 5, function(err, bcryptedPassword) {
if (err) {
return reject('Unable to create password.');
} else {
options.encrypted_password = bcryptedPassword;
return resolve(options);
}
});
})
}